-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
JUnit Jupiter @Nested tests do not run when selecting enclosing class with Surefire #1343
Comments
This is an interesting use case - I don't believe it represents a bug in JUnit 5 or in Surefire - Surefire provides a generalized way to discover tests, filter them and then executes them individually. It adapts to each test engine via the Provider API. When you run Surefire has recently added the ability to filter on method names to the So, it appears that a feature request needs to be made to the Surefire project. This could go one of two ways:
|
While Surefire provides the filter, it's the Provider's responsibility to apply it. This is what we currently do: Lines 28 to 55 in 4c8c469
I'm wondering whether we should add a special case when the test class is an inner class (i.e. it has an enclosing class and is not static), the |
@marcphilipp I'd forgotten that the Would there ever be a need to execute a single test method within an inner (@nested) class? - Perhaps a pseudo-filter something like |
FYI: I reproduced the bug discussed in the above SO comment. Non-private, static, nested test classes are also not executed via the JUnit Platform Maven Surefire provider when executing The OP for the aforementioned SO post will likely create a separate issue for that, but I wanted to make sure it's mentioned here as well, so that we don't forget it. |
FYI: the solution to this issue may be the same as for #1377. Namely, Maven Surefire excludes all nested classes by default! http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#excludes |
Tentatively slated for 5.2 GA in order to verify whether or not the fix for #1377 covers this use case as well. |
in progress: investigating |
Findings: After adding a The following does not execute the nested test class.
However, the following does execute the nested test class. Note the trailing
After further analysis, I have determined that the above behavior is also experienced even if the "no excludes" work-around discussed in #1377 is not applied. In summary, the "no excludes" work-around discussed in #1377 does not resolve this issue, and I am therefore moving this to 5.3. |
@sormuras Sorry if I'm being dense, but I can't tell from the history. Was this fixed, or was it closed for another reason? |
I'm in the process of moving Surefire-related issues over to https://issues.apache.org/jira/projects/SUREFIRE/issues |
Thanks. |
Overview
Per Marc Philipp's request on Stack Overflow:
I'm trying to use JUnit Jupiter in my side project as a trial before migrating my main project. I'd like to use
@Nested
tests to make my test classes cleaner.Everything is fine when I ran my test suite as a whole. However, as soon as I try running just a single test,
@Nested
ones are not executed.Using JUnit 5.1.0, JUnit platform 1.1.0
Test class:
Related Issues
The text was updated successfully, but these errors were encountered: