|
| 1 | +package org.apache.maven.surefire.its.jiras; |
| 2 | + |
| 3 | +/* |
| 4 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 5 | + * or more contributor license agreements. See the NOTICE file |
| 6 | + * distributed with this work for additional information |
| 7 | + * regarding copyright ownership. The ASF licenses this file |
| 8 | + * to you under the Apache License, Version 2.0 (the |
| 9 | + * "License"); you may not use this file except in compliance |
| 10 | + * with the License. You may obtain a copy of the License at |
| 11 | + * |
| 12 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | + * |
| 14 | + * Unless required by applicable law or agreed to in writing, |
| 15 | + * software distributed under the License is distributed on an |
| 16 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 17 | + * KIND, either express or implied. See the License for the |
| 18 | + * specific language governing permissions and limitations |
| 19 | + * under the License. |
| 20 | + */ |
| 21 | + |
| 22 | +import static java.nio.charset.StandardCharsets.UTF_8; |
| 23 | + |
| 24 | +import java.util.Arrays; |
| 25 | + |
| 26 | +import org.apache.maven.surefire.its.fixture.OutputValidator; |
| 27 | +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; |
| 28 | +import org.junit.Test; |
| 29 | +import org.junit.runner.RunWith; |
| 30 | +import org.junit.runners.Parameterized; |
| 31 | +import org.junit.runners.Parameterized.Parameter; |
| 32 | +import org.junit.runners.Parameterized.Parameters; |
| 33 | + |
| 34 | +/** |
| 35 | + * Integration Test for SUREFIRE-2117 |
| 36 | + */ |
| 37 | +@RunWith( Parameterized.class ) |
| 38 | +@SuppressWarnings( "checkstyle:magicnumber" ) |
| 39 | +public class Surefire2117XmlReportingNestedIT extends SurefireJUnit4IntegrationTestCase |
| 40 | +{ |
| 41 | + @Parameter |
| 42 | + @SuppressWarnings( "checkstyle:visibilitymodifier" ) |
| 43 | + public String jupiterVersion; |
| 44 | + |
| 45 | + @Parameters( name = "{0}" ) |
| 46 | + public static Iterable<?> junitJupiterVersions() |
| 47 | + { |
| 48 | + return Arrays.asList( "5.2.0", "5.8.2", "5.9.1" ); |
| 49 | + } |
| 50 | + |
| 51 | + @Test |
| 52 | + public void testXmlReport() |
| 53 | + { |
| 54 | + OutputValidator validator = unpack( "surefire-2117-xml-reporting-nested", "-" + jupiterVersion ) |
| 55 | + .sysProp( "junit5.version", jupiterVersion ) |
| 56 | + .executeTest() |
| 57 | + .verifyErrorFree( 9 ); |
| 58 | + |
| 59 | + validator.getSurefireReportsFile( "TEST-jira2117.NestedJupiterTest$A.xml", UTF_8 ) |
| 60 | + .assertContainsText( "<testcase name=\"level1_test\" " |
| 61 | + + "classname=\"jira2117.NestedJupiterTest$A\"" ); |
| 62 | + |
| 63 | + validator.getSurefireReportsFile( "TEST-jira2117.NestedJupiterTest$B$C.xml", UTF_8 ) |
| 64 | + .assertContainsText( "<testcase name=\"level2_test_nonparameterized\" " |
| 65 | + + "classname=\"jira2117.NestedJupiterTest$B$C\"" ) |
| 66 | + .assertContainsText( "<testcase name=\"level2_test_parameterized(String)[1] paramValue1\" " |
| 67 | + + "classname=\"jira2117.NestedJupiterTest$B$C\"" ) |
| 68 | + .assertContainsText( "<testcase name=\"level2_test_parameterized(String)[2] paramValue2\" " |
| 69 | + + "classname=\"jira2117.NestedJupiterTest$B$C\"" ); |
| 70 | + |
| 71 | + String expectedDisplayNameForNestedClassA = String.join( " ", |
| 72 | + "Display name of the main test class", |
| 73 | + "Display name of level 1 nested class A" ); |
| 74 | + |
| 75 | + validator.getSurefireReportsFile( "TEST-jira2117.NestedDisplayNameTest$A.xml", UTF_8 ) |
| 76 | + .assertContainsText( "<testcase name=\"level1_test_without_display_name\" " |
| 77 | + + "classname=\"" + expectedDisplayNameForNestedClassA + "\"" ) |
| 78 | + .assertContainsText( "<testcase name=\"Display name of level 1 test method\" " |
| 79 | + + "classname=\"" + expectedDisplayNameForNestedClassA + "\"" ); |
| 80 | + |
| 81 | + String expectedDisplayNameForNestedClassC = String.join( " ", |
| 82 | + "Display name of the main test class", |
| 83 | + "Display name of level 1 nested class B", |
| 84 | + "Display name of level 2 nested class C" ); |
| 85 | + |
| 86 | + validator.getSurefireReportsFile( "TEST-jira2117.NestedDisplayNameTest$B$C.xml", UTF_8 ) |
| 87 | + .assertContainsText( |
| 88 | + "<testcase name=\"Display name of non-parameterized level 2 test method\" " |
| 89 | + + "classname=\"" + expectedDisplayNameForNestedClassC + "\"" ) |
| 90 | + .assertContainsText( |
| 91 | + "<testcase name=\"Display name of parameterized level 2 test method[1] paramValue1\" " |
| 92 | + + "classname=\"" + expectedDisplayNameForNestedClassC + "\"" ) |
| 93 | + .assertContainsText( |
| 94 | + "<testcase name=\"Display name of parameterized level 2 test method[2] paramValue2\" " |
| 95 | + + "classname=\"" + expectedDisplayNameForNestedClassC + "\"" ); |
| 96 | + } |
| 97 | + |
| 98 | +} |
0 commit comments