-
Notifications
You must be signed in to change notification settings - Fork 542
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SUREFIRE-2117] Include package + outer classes in XML report of @nested
- Loading branch information
1 parent
7ade5cc
commit 4f4ac97
Showing
6 changed files
with
391 additions
and
1 deletion.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
...s/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2117XmlReportingNestedIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package org.apache.maven.surefire.its.jiras; | ||
|
||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.apache.maven.surefire.its.fixture.OutputValidator; | ||
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.Parameter; | ||
import org.junit.runners.Parameterized.Parameters; | ||
|
||
/** | ||
* Integration Test for SUREFIRE-2117 | ||
*/ | ||
@RunWith( Parameterized.class ) | ||
@SuppressWarnings( "checkstyle:magicnumber" ) | ||
public class Surefire2117XmlReportingNestedIT extends SurefireJUnit4IntegrationTestCase | ||
{ | ||
@Parameter | ||
@SuppressWarnings( "checkstyle:visibilitymodifier" ) | ||
public String jupiterVersion; | ||
|
||
@Parameters( name = "{0}" ) | ||
public static Iterable<?> junitJupiterVersions() | ||
{ | ||
return Arrays.asList( "5.2.0", "5.8.2", "5.9.1" ); | ||
} | ||
|
||
@Test | ||
public void testXmlReport() | ||
{ | ||
OutputValidator validator = unpack( "surefire-2117-xml-reporting-nested", "-" + jupiterVersion ) | ||
.sysProp( "junit5.version", jupiterVersion ) | ||
.executeTest() | ||
.verifyErrorFree( 9 ); | ||
|
||
validator.getSurefireReportsFile( "TEST-jira2117.NestedJupiterTest$A.xml", UTF_8 ) | ||
.assertContainsText( "<testcase name=\"level1_test\" " | ||
+ "classname=\"jira2117.NestedJupiterTest$A\"" ); | ||
|
||
validator.getSurefireReportsFile( "TEST-jira2117.NestedJupiterTest$B$C.xml", UTF_8 ) | ||
.assertContainsText( "<testcase name=\"level2_test_nonparameterized\" " | ||
+ "classname=\"jira2117.NestedJupiterTest$B$C\"" ) | ||
.assertContainsText( "<testcase name=\"level2_test_parameterized(String)[1] paramValue1\" " | ||
+ "classname=\"jira2117.NestedJupiterTest$B$C\"" ) | ||
.assertContainsText( "<testcase name=\"level2_test_parameterized(String)[2] paramValue2\" " | ||
+ "classname=\"jira2117.NestedJupiterTest$B$C\"" ); | ||
|
||
String expectedDisplayNameForNestedClassA = String.join( " ", | ||
"Display name of the main test class", | ||
"Display name of level 1 nested class A" ); | ||
|
||
validator.getSurefireReportsFile( "TEST-jira2117.NestedDisplayNameTest$A.xml", UTF_8 ) | ||
.assertContainsText( "<testcase name=\"level1_test_without_display_name\" " | ||
+ "classname=\"" + expectedDisplayNameForNestedClassA + "\"" ) | ||
.assertContainsText( "<testcase name=\"Display name of level 1 test method\" " | ||
+ "classname=\"" + expectedDisplayNameForNestedClassA + "\"" ); | ||
|
||
String expectedDisplayNameForNestedClassC = String.join( " ", | ||
"Display name of the main test class", | ||
"Display name of level 1 nested class B", | ||
"Display name of level 2 nested class C" ); | ||
|
||
validator.getSurefireReportsFile( "TEST-jira2117.NestedDisplayNameTest$B$C.xml", UTF_8 ) | ||
.assertContainsText( | ||
"<testcase name=\"Display name of non-parameterized level 2 test method\" " | ||
+ "classname=\"" + expectedDisplayNameForNestedClassC + "\"" ) | ||
.assertContainsText( | ||
"<testcase name=\"Display name of parameterized level 2 test method[1] paramValue1\" " | ||
+ "classname=\"" + expectedDisplayNameForNestedClassC + "\"" ) | ||
.assertContainsText( | ||
"<testcase name=\"Display name of parameterized level 2 test method[2] paramValue2\" " | ||
+ "classname=\"" + expectedDisplayNameForNestedClassC + "\"" ); | ||
} | ||
|
||
} |
98 changes: 98 additions & 0 deletions
98
surefire-its/src/test/resources/surefire-2117-xml-reporting-nested/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one | ||
~ or more contributor license agreements. See the NOTICE file | ||
~ distributed with this work for additional information | ||
~ regarding copyright ownership. The ASF licenses this file | ||
~ to you under the Apache License, Version 2.0 (the | ||
~ "License"); you may not use this file except in compliance | ||
~ with the License. You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, | ||
~ software distributed under the License is distributed on an | ||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
~ KIND, either express or implied. See the License for the | ||
~ specific language governing permissions and limitations | ||
~ under the License. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.apache.maven.plugins.surefire</groupId> | ||
<artifactId>surefire-2117-xml-reporting-nested</artifactId> | ||
<version>1.0</version> | ||
<name>Test for: JUnit5Xml30StatelessReporter and Nested</name> | ||
|
||
<properties> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
</properties> | ||
|
||
<!-- | ||
Declare "junit-jupiter-engine" dependency because the | ||
Jupiter Engine is needed at test runtime. Artifacts | ||
needed for test compilation, like "junit-jupiter-api", | ||
are pulled-in via transitive dependency resolution. | ||
--> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<version>${junit5.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-params</artifactId> | ||
<version>${junit5.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.0</version> | ||
<configuration> | ||
<encoding>UTF-8</encoding> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>${surefire.version}</version> | ||
<configuration> | ||
<forkCount>1.0C</forkCount> | ||
<redirectTestOutputToFile>true</redirectTestOutputToFile> | ||
<statelessTestsetReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter"> | ||
<disable>false</disable> | ||
<version>3.0</version> | ||
<usePhrasedFileName>false</usePhrasedFileName> | ||
<usePhrasedTestSuiteClassName>true</usePhrasedTestSuiteClassName> | ||
<usePhrasedTestCaseClassName>true</usePhrasedTestCaseClassName> | ||
<usePhrasedTestCaseMethodName>true</usePhrasedTestCaseMethodName> | ||
</statelessTestsetReporter> | ||
<consoleOutputReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5ConsoleOutputReporter"> | ||
<disable>false</disable> | ||
<encoding>UTF-8</encoding> | ||
<usePhrasedFileName>false</usePhrasedFileName> | ||
</consoleOutputReporter> | ||
<statelessTestsetInfoReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoReporter"> | ||
<disable>false</disable> | ||
<usePhrasedFileName>false</usePhrasedFileName> | ||
<usePhrasedClassNameInRunning>true</usePhrasedClassNameInRunning> | ||
<usePhrasedClassNameInTestCaseSummary>true</usePhrasedClassNameInTestCaseSummary> | ||
</statelessTestsetInfoReporter> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
69 changes: 69 additions & 0 deletions
69
...rces/surefire-2117-xml-reporting-nested/src/test/java/jira2117/NestedDisplayNameTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package jira2117; | ||
|
||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
@DisplayName( "Display name of the main test class" ) | ||
class NestedDisplayNameTest | ||
{ | ||
@Nested | ||
@DisplayName( "Display name of level 1 nested class A" ) | ||
class A | ||
{ | ||
@Test | ||
void level1_test_without_display_name() | ||
{ | ||
} | ||
|
||
@Test | ||
@DisplayName( "Display name of level 1 test method" ) | ||
void level1_test_with_display_name() | ||
{ | ||
} | ||
} | ||
|
||
@Nested | ||
@DisplayName( "Display name of level 1 nested class B" ) | ||
class B | ||
{ | ||
@Nested | ||
@DisplayName( "Display name of level 2 nested class C" ) | ||
class C | ||
{ | ||
@Test | ||
@DisplayName( "Display name of non-parameterized level 2 test method" ) | ||
void level2_test_nonparameterized() | ||
{ | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"paramValue1", "paramValue2"}) | ||
@DisplayName( "Display name of parameterized level 2 test method" ) | ||
void level2_test_parameterized(String paramValue) | ||
{ | ||
} | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...esources/surefire-2117-xml-reporting-nested/src/test/java/jira2117/NestedJupiterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package jira2117; | ||
|
||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
class NestedJupiterTest | ||
{ | ||
@Nested | ||
class A | ||
{ | ||
@Test | ||
void level1_test() | ||
{ | ||
} | ||
} | ||
|
||
@Nested | ||
class B | ||
{ | ||
@Nested | ||
class C | ||
{ | ||
@Test | ||
void level2_test_nonparameterized() | ||
{ | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"paramValue1", "paramValue2"}) | ||
void level2_test_parameterized(String paramValue) | ||
{ | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.