[ https://issues.apache.org/jira/browse/SUREFIRE-2074?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tibor Digana updated SUREFIRE-2074: ----------------------------------- Fix Version/s: waiting-for-apache-feedback > 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 > Priority: Minor > Fix For: waiting-for-apache-feedback > > > 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)