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