-
Notifications
You must be signed in to change notification settings - Fork 77
Handle duplicate test names in report #335
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?
Conversation
@illicitonion can you please review? |
#351 recently landed. I'm pretty sure that we still need this PR, but could you please confirm? If we do, I'll be happy to merge this. Please also accept my apologies for the very slow review. |
Yes, we still need this. |
Can you try adding the following to your .bazelrc to test:
Which would make the output go from: For https://github.com/bazel-contrib/rules_jvm/blob/main/comparative-tests/src/test/java/com/github/bazel_contrib/contrib_rules_jvm/comparative/ParameterisedTest.java. If you don't want to get the values of each parameter you can just remove the This change in the default naming for ParameterizedTests would apply after various annotation name settings (see https://docs.junit.org/current/user-guide/#writing-tests-display-names for more details). |
@christianladam this is talking about junitparmsrunner. This flag works for Junit5 Parameterized test. |
Do you want it to ignore duplicates? How would one know which result its actually showing? It feels like it'd be better to change the format of the JUnitParams stuff to handle it better. Since JUnitParamsRunner is junit4, do you know what the behavior is when using the standard junit4 test runner provided by bazel? Ideally we'd be handling things the same in both cases. If it's having this issue in both cases, then ideally there'd be a solution that works for both where potentially the JUnitParams formatting via https://github.com/Pragmatists/JUnitParams/blob/master/src/main/java/junitparams/naming/MacroSubstitutionNamingStrategy.java could be overridden or configured. I'm guessing the junit4 code might work fine but the junit5 doesn't because rules_jvm tries to match the behavior of gradle/maven when it comes to the dynamic naming cases. |
@shs96c can you please take a look. |
JUnitParams generates report names based on parameter values rather than parameter types, which can result in duplicate test names in the XML output. This situation arises when two test methods have identical names but differ in parameter types; however, their string representations may be the same (e.g., Integer 1 and Long 1).
Added logic to ignore tests with duplicate names in test report names.