You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Henrik Josefsson (Jira)" <ji...@apache.org> on 2022/04/16 10:57:00 UTC
[jira] [Created] (SUREFIRE-2074) Junit 5 @Nested Tests executes when excluded
Henrik Josefsson created SUREFIRE-2074:
------------------------------------------
Summary: Junit 5 @Nested Tests executes when excluded
Key: SUREFIRE-2074
URL: https://issues.apache.org/jira/browse/SUREFIRE-2074
Project: Maven Surefire
Issue Type: Bug
Components: JUnit 5.x support
Affects Versions: 3.0.0-M6
Reporter: Henrik Josefsson
Test classes with the Junit 5 `@Nested` annotation is executed even when explicitly excluded with the `<exclude>` tag.
h2. Minimal reproducing example
[https://github.com/Steinstark/surefire-issue] see the IssueTest.
h2. Surefire configuration
{code:java}
<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>{code}
h2. Expected behavior
The tests inside the `@Nested` excluded class is not run.
h2. Actual behavior
The tests inside the `@Nested` excluded class is run.
h2. 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.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)