Skip to content

Introduce List support in the Arguments API for parameterized tests #4535

@asarkar

Description

@asarkar

Overview

Please excuse the somewhat long context, which I feel is necessary to establish the need for this ticket.

I run golden tests by reading from a zip file, that has pairs of input and output files. Please note that the following problem will exist even if these in/out files were read from a directory instead of a zip file.

Each individual test is fed by a @MethodSource, that calls the zip utility with two functions, that are invoked for each in/out pair, respectively. Since the order of the in/out files is nondeterministic, the results of these function invocations are saved in a map. The code in question can be seen here.

Here’s where the Arguments API is lacking for non-trivial use cases.

  1. There’s no way to concat two Arguments or add an item to an existing Arguments.
  2. An Arguments can only be created from an array, not a collection.
  3. In the above use case, the return type of the in/out functions could be Arguments, and we would concat the two Arguments, either by append or prepend, based on whether in or out is encountered first. We could also create the Arguments from collections, not arrays. Currently, all of these have to done by first pulling the array out of an Arguments, creating a new one, and copying stuff over.

Original Proposal

  • Add a constructor that accepts a Collection.
  • Add a method append/add/addLast that appends an item to an existing Arguments, and returns a new one.
  • Add a method prepend/addFirst
  • Add a method concat that appends all items of the Arguments parameter to the Arguments it’s called on.
  • Add a method size.

Current Deliverables

  • Add static Arguments Arguments.of(List<@Nullable Object>)
  • Add static Arguments Arguments.arguments(List<@Nullable Object>)
  • Add static ArgumentSet Arguments.argumentSet(String, List<@Nullable Object>)
  • Add default List<@Nullable Object> Arguments.toList(), implemented as new ArrayList<>(List.of(get())) (or similar) so that the returned List is mutable.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions