Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
3.0.0-M6
-
None
Description
Test classes with the Junit 5 `@Nested` annotation is executed even when explicitly excluded with the `<exclude>` tag.
Minimal reproducing example
https://github.com/Steinstark/surefire-issue see the IssueTest.
Surefire configuration
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M6</version> <configuration> <excludes> <exclude>**/IssueTest$NestedTests</exclude> </excludes> </configuration> </plugin>
Expected behavior
The tests inside the `@Nested` excluded class is not run.
Actual behavior
The tests inside the `@Nested` excluded class is run.
Additional info
I believe the problem is caused by only setting the selectors based on the exact classes surefire is expected to run for the LauncherDiscoveryRequestBuilder in JunitPlatformProvider but as far as I can tell Junit will by default discover `@Nested` classes aswell from the selectors.
The solution is probably to provide a filter in addition to the selector. Not sure if it is a good solution but locally I changed the newFilters method to always add the TestMethodFilter and it appear to have worked. Might be something worth looking further into at least.