Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
3.1.2
-
None
-
None
Description
Example Test Class
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; class ExampleTest { @Test void outerTest() { assertTrue(true); } @Nested class InnerExampleTest { @Test void innerTest() { assertTrue(true); } } }
Expected Result
One TEST-ExampleTest.xml file containing the results of both tests or two files (TEST-ExampleTest.xml and TEST-ExampleTest$InnerExampleTest.xml) containing the results of their tests.
Actual Result
- TEST-ExampleTest.xml does not contain any test case.
- TEST-ExampleTest$InnerExampleTest.xml contains results for both test cases.
Workaround
Do not put any tests into the parent class if nested classes are used.
Analysis
org.apache.maven.surefire.junitplatform.RunListenerAdapter does not distinguish between the parent and the nested classes. Both are reported as new test sets.
org.apache.maven.plugin.surefire.report.TestSetRunListener does not support nested test sets, so the test set of the nested class overrides the test set of the parent class.