-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add List-based support to Arguments API #4574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add List-based support to Arguments API #4574
Conversation
3a32cf8 to
9de99b7
Compare
9de99b7 to
3f3aa29
Compare
junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/Arguments.java
Outdated
Show resolved
Hide resolved
junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/Arguments.java
Outdated
Show resolved
Hide resolved
junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/Arguments.java
Outdated
Show resolved
Hide resolved
...t-jupiter-params/src/main/java/org/junit/jupiter/params/provider/EmptyArgumentsProvider.java
Outdated
Show resolved
Hide resolved
|
|
||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move these next to the other static factory methods above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion! I'll move the method next to the other static factory methods to keep things consistent.
cbde5ed to
a2ca294
Compare
a2ca294 to
d566f95
Compare
junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/Arguments.java
Outdated
Show resolved
Hide resolved
junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/Arguments.java
Outdated
Show resolved
Hide resolved
junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/Arguments.java
Outdated
Show resolved
Hide resolved
jupiter-tests/src/test/java/org/junit/jupiter/params/provider/ArgumentsTests.java
Outdated
Show resolved
Hide resolved
jupiter-tests/src/test/java/org/junit/jupiter/params/provider/ArgumentsTests.java
Outdated
Show resolved
Hide resolved
jupiter-tests/src/test/java/org/junit/jupiter/params/provider/ArgumentsTests.java
Show resolved
Hide resolved
jupiter-tests/src/test/java/org/junit/jupiter/params/provider/ArgumentsTests.java
Outdated
Show resolved
Hide resolved
jupiter-tests/src/test/java/org/junit/jupiter/params/provider/ArgumentsTests.java
Outdated
Show resolved
Hide resolved
jupiter-tests/src/test/java/org/junit/jupiter/params/provider/ArgumentsTests.java
Show resolved
Hide resolved
junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/Arguments.java
Outdated
Show resolved
Hide resolved
junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/Arguments.java
Outdated
Show resolved
Hide resolved
junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/Arguments.java
Outdated
Show resolved
Hide resolved
junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/Arguments.java
Outdated
Show resolved
Hide resolved
vlsi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering: have you considered Iterable<? extends @Nullable Object> rather than using a plain List?
Based on my experience with checkerframework's @Nullable, I would suggest List<? extends @Nullable Object> rather than List<Object>.
I've asked jspecify to clarify the documentation anyways: jspecify/jspecify#748
At the same time, it would be nice to add tests that pass something like List<String> to the newly added methods.
For instance, from(Files.readAllLines("path")). I guess the code won't compile if the method uses List<Object> signatures.
junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/Arguments.java
Outdated
Show resolved
Hide resolved
junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/Arguments.java
Outdated
Show resolved
Hide resolved
|
One more thing: |
I didn't know that but sounds like you're right, according to the spec:
Therefore, I think using
The use case we're addressing here is constructing new |
junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/Arguments.java
Outdated
Show resolved
Hide resolved
|
@marcphilipp , sorry for asking the same thing twice, however, could you please clarify why do you mean To me the second case of #4535 sounds like a natural case for using
I've no issues if Of course, it would be great if Java had something like If you mean you force |
The use case we're trying to address here is to go from an existing
We'll discuss that in one of our next team calls. |
|
Team decision: Use |
|
@mariokhoury4 thanks for working on this! Unfortunately we took a long time before we could discuss this and imagine you'll have moved on. So I'll pick up the remaining changes and do some polishing to wrap this up in the next few weeks. |
Using wildcards in the method parameter is fine, but for the return type of |
- Accessors - Factory methods - Varargs before iterables - Static imports after short-named variants
🔎 No tests executed 🔎🏷️ Commit: 55720a1 |
Overview
This PR adds List-based support to the
ArgumentsAPI for parameterized tests.New additions:
Arguments.of(List<@Nullable Object>)Arguments.arguments(List<@Nullable Object>)(alias)Arguments.argumentSet(String, List<@Nullable Object>)Arguments.toList()— returns a mutableList<@Nullable Object>These additions make it easier to dynamically build arguments from collections when using
@ParameterizedTest.All additions are tested in
ArgumentsTests.java.Fixes #4535
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@APIannotations