You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Andreas Pabst (Jira)" <ji...@apache.org> on 2022/10/03 16:08:00 UTC

[jira] [Created] (SUREFIRE-2117) XML report omits package and outer class name for tests in @Nested inner class if testset reporter is configured to use phrased naming

Andreas Pabst created SUREFIRE-2117:
---------------------------------------

             Summary: XML report omits package and outer class name for tests in @Nested inner class if testset reporter is configured to use phrased naming
                 Key: SUREFIRE-2117
                 URL: https://issues.apache.org/jira/browse/SUREFIRE-2117
             Project: Maven Surefire
          Issue Type: Bug
          Components: JUnit 5.x support, xml generation
    Affects Versions: 3.0.0-M7
            Reporter: Andreas Pabst


h3. Description of the issue

Given a test class with tests in nested inner classes as follows:
{code:java}
package mypackage;

class OuterTestClass {

    @Nested
    class A {

        @Test
        void level1_test() { ... }

        @Nested
        class B {

            @Test
            void level2_test() { ... }

        }
    }
}
{code}
and a surefire configuration that includes the following
{code:xml}
<statelessTestsetReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter">
    <version>3.0</version>
    <usePhrasedTestSuiteClassName>true</usePhrasedTestSuiteClassName>
    <usePhrasedTestCaseClassName>true</usePhrasedTestCaseClassName>
    <usePhrasedTestCaseMethodName>true</usePhrasedTestCaseMethodName>
</statelessTestsetReporter>
{code}
the XML reports will look like this:
{code:xml}
<testcase name="level1_test" classname="A" time="0"/>
{code}
{code:xml}
<testcase name="level2_test" classname="B" time="0"/>
{code}
i.e. the package name, outer class name and higher level inner class names are not included in the classname attribute.

I would expect something more like this:
{code:xml}
<testcase name="level1_test" classname="mypackage.OuterTestClass$A" time="0"/>
{code}
{code:xml}
<testcase name="level2_test" classname="mypackage.OuterTestClass$A$B" time="0"/>
{code}
This happens also if `@DisplayName` is used by the way. Only the display name of the leaf inner class is included in the report in that case.
h3. Some context on why this is bad

Any software that parses the surefire XML reports is missing out on potentially important context information.
h3. Solution ideas

The root cause is similar to SUREFIRE-1914. Therefore, a similar fix can be provided: the hierarchy of class source test identifiers needs to be taken into account to determine the classname attribute.

I will provide a pull request that contains ITs that reproduce the issue and a proposed fix.
h3. Workaround

A workaround is to explicitly specify a `@DisplayName` that also contains the information otherwise provided by the surrounding inner class(es), the outer class and the package name.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)