View Javadoc
1   package org.apache.maven.surefire.its;
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 org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
23  import org.apache.maven.surefire.its.fixture.SurefireLauncher;
24  import org.junit.Test;
25  import org.junit.runner.RunWith;
26  import org.junit.runners.Parameterized;
27  
28  import java.util.Arrays;
29  import java.util.Collection;
30  
31  import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;
32  import static org.junit.runners.Parameterized.Parameter;
33  import static org.junit.runners.Parameterized.Parameters;
34  
35  /**
36   * Test simple TestNG listener and reporter
37   *
38   * @author <a href="mailto:dfabulich@apache.org">Dan Fabulich</a>
39   * @author <a href="mailto:krosenvold@apache.org">Kristian Rosenvold</a>
40   */
41  @RunWith( Parameterized.class )
42  public class CheckTestNgListenerReporterIT
43      extends SurefireJUnit4IntegrationTestCase
44  {
45      @Parameters( name = "{index}: TestNG {0}" )
46      public static Collection<Object[]> data()
47      {
48          return Arrays.asList(new Object[][] {
49              { "5.6", "jdk15", 1.5d }, // First TestNG version with reporter support
50              { "5.7", "jdk15", 1.5d }, // default version from pom of the test case
51              { "5.10", "jdk15", 1.5d },
52              { "5.13", null, 1.5d }, // "reporterslist" param becomes String instead of List<ReporterConfig>
53                          // "listener" param becomes String instead of List<Class>
54  
55                  // configure(Map) in 5.14.1 and 5.14.2 is transforming List<Class> into a String with a space as separator.
56                  // Then configure(CommandLineArgs) splits this String into a List<String> with , or ; as separator => fail.
57                  // If we used configure(CommandLineArgs), we would not have the problem with white spaces.
58              //{ "5.14.1", null, "1.5" }, // "listener" param becomes List instead of String
59                              // Fails: Issue with 5.14.1 and 5.14.2 => join with <space>, split with ","
60                              // TODO will work with "configure(CommandLineArgs)"
61              //{ "5.14.2", null, "1.5" }, // ReporterConfig is not available
62  
63              //{ "5.14.3", null, "1.5" }, // TestNG uses "reporter" instead of "reporterslist"
64                            // Both String or List are possible for "listener"
65                            // Fails: not able to test due to system dependency org.testng:guice missed the path and use to break CI
66                            // ClassNotFoundException: com.beust.jcommander.ParameterException
67  
68              //{ "5.14.4", null, "1.5" }, { "5.14.5", null, "1.5" }, // Fails: not able to test due to system dependency org.testng:guice missed the path and use to break CI
69                                          // ClassNotFoundException: com.beust.jcommander.ParameterException
70  
71              { "5.14.6", null, 1.5d }, // Usage of org.testng:guice removed
72              { "5.14.9", null, 1.5d }, // Latest 5.14.x TestNG version
73              { "6.0", null, 1.5d },
74              { "6.9.9", null, 1.7d } // Currently latest TestNG version
75          });
76      }
77  
78      @Parameter
79      public String version;
80  
81      @Parameter(1)
82      public String classifier;
83  
84      @Parameter(2)
85      public double javaVersion;
86  
87      @Test
88      public void testNgListenerReporter()
89      {
90          assumeJavaVersion( javaVersion );
91          final SurefireLauncher launcher = unpack( "testng-listener-reporter", "_" + version )
92                                                    .sysProp( "testNgVersion", version );
93  
94          if ( classifier != null )
95          {
96              launcher.sysProp( "testNgClassifier", "jdk15" );
97          }
98  
99          launcher.executeTest()
100                 .verifyErrorFree( 1 )
101                 .getTargetFile( "resultlistener-output.txt" ).assertFileExists()
102                 .getTargetFile( "suitelistener-output.txt" ).assertFileExists()
103                 .getTargetFile( "reporter-output.txt" ).assertFileExists();
104     }
105 }