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