-
Notifications
You must be signed in to change notification settings - Fork 541
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
[SUREFIRE-1711] Support @ParameterizedTest for JUnit 5 test reruns #252
Conversation
LGTM, I am waiting for the build result. |
The only difference is the identifier at the end. So in your example if your parameters were:
The display names would be what you're looking for:
Sounds good to me |
ok, that's also good alternative. Can you then prepare a PR with the legacy name on the top of this commit? btw, And if we additionally transfer the parameters in |
@Col-E |
For clarification, are you asking for using the legacy name in RunListenerAdapter where |
Yes, this was my plan but we have to run the unit tests and Platform ITs because i am not sure if they would succeed. We may have a problem with the brackets but the tests will show us a problem. |
Reporting still uses the method Since normal tests do not have brackets we can easily separate the normal tests from the parameterized tests by checking if the legacy name contains a If we want to show that different runs of Before I do anything to change the report format I would like to have a minimal example of what the xml output would be for parameterized support just to be clear on the intended format. |
ok, let's change the methodology. The problem with JUnit5 and the Adapter is that we never know what annotations are used. We only can see some strings and signatures and list of method arguments but that's basically all regarding the test method. |
@Col-E |
public class AppTest {
@Test
public void pass() { }
@Test
public void fail() {
Assertions.assertTrue(false);
}
static List<Object[]> params() {
return Arrays.asList(
new Object[] { "One" },
new Object[] { "Two" },
new Object[] { "Three" } );
}
@ParameterizedTest
@MethodSource("params")
public void parameterizedPassOnThree(String key) {
Assertions.assertEquals("Three", key);
}
@ParameterizedTest
@MethodSource("params")
public void parameterizedFailAlways(String key) {
Assertions.assertEquals("None", key);
}
} Oh yeah... I see that now. But I also noticed something else: Running with no config options -
Running with no config options -
The parameter-set-number used to be reported but no longer is... 🤔 |
The answer is in the history of the Adapter class. |
Is this already finished? I tried to run a test with rerun and it shows the result as a success even if the test fails in one of the cases. And it doesn't rerun the failing test, and I set the parameter for it to 3. |
@Seijan In this issue we only fixed our previous fault in the code. |
@Col-E |
Yeah, I've just been a bit busy recently with coursework. |
@Col-E |
Sorry about not finishing everything up, my schedule should be clearing up for a bit soon for future contributions. |
@Col-E @Col-E |
I have tested the new rerun feature with parameterized tests. It generally looks good but there is a problem with the exported xml report files when running the tests in parallel. (Parallel feature from junit 5). The reports got mixed. Normally there are only test results of one test class per xml file. But now there are random testcase tags from other classes inserted in files which does not belong to this class. This causes our pipeline to report wrong test results. CC: @Seijan |
@Micky002 |
Sry i just found the roadmap and saw that exactly this will be done in M5. Thanks for the info :) |
@Tibor17 When using "surefire-junit-platform" as the provider, selecting a single parametrized test (junit4) doesn't work as mentioned here- http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#test Using mvn test -Dtest=sampletests.JUnit4ParametrizedExampleTest#sampleTest[true] for below example works only when "surefire-junit47" provider is added .
=================================== But for the junit5 parameterized test I couldn't run a single Parameterised with any of the below options, any idea what I'm doing wrong here? mvn test -Dtest=sampletests.JUnit5ParametrizedExampleTest#sampleTest[true]
|
This change fixes the issue discussed in #245 where
@ParameterizedTest
were not supported by the JUnitPlatformProvider.The fix is rather simple, moving from
DiscoverySelectors.selectMethod
toDiscoverySelectors.selectUniqueId
. Included are additions toJUnitPlatformProviderTest
showing this feature is now supported.I have detailed why this is a good alternative to parsing the legacy name in a gist: "The case for UniqueId over Legacy Name "
As mentioned in the gist, using
selectUniqueId
allows us to undo the changes made toRunListenerAdapter.toClassMethodName
that were made in #245, which I've also included in this PR.