-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Include parameter names in default name of @ParameterizedTest #2040
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
Comments
Tentatively slated for 5.6 M1 solely for the purpose of team discussion and triaging. |
FYI: this would need to be an opt-in feature. In addition, parameter names are not always present in the compiled byte code. To include them in the byte code, the test code must be compiled with the |
You assume I use Java, however, Kotlin does retain parameter names always 😉 |
@sbrannen Could we check whether parameter names are present and include them only if so? |
Yes. See |
Team Decision: Introduce new |
@vlsi Would you be interested in submitting a PR for this? |
FYI, just started working on it. |
@junit-team/junit-lambda If one of these conditions are encountered for one of the parameters, do we fallback on the current behavior for all of them or do we still add names for the other parameters? (I'd rather fallback on the |
I think we could support the case of mixed position and accessor/aggregator arguments, i.e. for test like the following: @ParameterizedTest
@ValueSource(ints = { 1, 2, 3 })
void testWithValueSource(int value, ArgumentsAccessor accessor) {
assertTrue(value > 0 && value < 4);
} The display names currently are We should be able to extract the logic in |
I'm wondering if we should call the pattern |
Indeed. Better to stay consistent and go with camel case there. Good catch. |
Introduced a new `{arguments_with_names}` pattern in `@ParameterizedTest`, which is now used in the default name pattern. The parameter names are included only if they are present in the bytecode and if the parameter types are known (`ArgumentsAccessor` and `ArgumentsAggregator` are therefore ignored). Closes #2040.
Suppose I have a test:
The result looks unreadable:
It does not really help if the test fails.
That means every time I use
@ParameterizedTest
I have to declare test name explicitly.That is sad.
What if JUnit generated something like
?
It would make lots of tests and test failures easier to understand.
I'm OK if it is
{arguments_with_names}
. Then I could create@ParameterizedTestWithArgNames
annotation that uses detailed name.PS. I've seen #1154, however, I don't really want to deal and/or declare resolvers.
The text was updated successfully, but these errors were encountered: