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 java.io.File;
23  import java.util.List;
24  
25  import org.apache.maven.plugins.surefire.report.ReportTestSuite;
26  import org.apache.maven.surefire.its.fixture.HelperAssertions;
27  import org.apache.maven.surefire.its.fixture.OutputValidator;
28  import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
29  import org.junit.Ignore;
30  import org.junit.Test;
31  
32  import static org.junit.Assert.assertEquals;
33  import static org.junit.Assert.assertTrue;
34  
35  /**
36   * Basic suite test using all known versions of TestNG. Used for regression testing Surefire against old versions. To
37   * check new versions of TestNG work with current versions of Surefire, instead run the full test suite with
38   * -Dtestng.version=5.14.2 (for example)
39   *
40   * @author <a href="mailto:dfabulich@apache.org">Dan Fabulich</a>
41   * @author <a href="mailto:krosenvold@apache.org">Kristian Rosenvold</a>
42   */
43  public class CheckTestNgVersionsIT
44      extends SurefireJUnit4IntegrationTestCase
45  {
46  
47      @Test public void test47()
48          throws Exception
49      {
50          runTestNgTest( "4.7" );
51      }
52  
53      @Test @Ignore( "5.0 and 5.0.1 jars on central are malformed SUREFIRE-375 + MAVENUPLOAD-1024" ) public void XXXtest50()
54          throws Exception
55      {
56          runTestNgTest( "5.0" );
57      }
58  
59      @Test @Ignore( "5.0 and 5.0.1 jars on central are malformed SUREFIRE-375 + MAVENUPLOAD-1024" ) public void XXXtest501()
60          throws Exception
61      {
62          runTestNgTest( "5.0.1" );
63      }
64  
65      @Test public void test502()
66          throws Exception
67      {
68          runTestNgTest( "5.0.2" );
69      }
70  
71      @Test public void test51()
72          throws Exception
73      {
74          runTestNgTest( "5.1" );
75      }
76  
77      @Test public void test55()
78          throws Exception
79      {
80          runTestNgTest( "5.5" );
81      }
82  
83      @Test public void test56()
84          throws Exception
85      {
86          runTestNgTest( "5.6" );
87      }
88  
89      @Test public void test57()
90          throws Exception
91      {
92          runTestNgTest( "5.7" );
93      }
94  
95      @Test public void test58()
96          throws Exception
97      {
98          runTestNgTest( "5.8" );
99      }
100 
101     @Test public void test59()
102         throws Exception
103     {
104         runTestNgTest( "5.9" );
105     }
106 
107     @Test public void test510()
108         throws Exception
109     {
110         runTestNgTest( "5.10" );
111     }
112 
113     @Test public void test511()
114         throws Exception
115     {
116         runTestNgTest( "5.11" );
117     }
118 
119     @Test public void test512()
120         throws Exception
121     {
122         runTestNgTest( "5.12.1" );
123     }
124 
125     @Test public void test513()
126         throws Exception
127     {
128         runTestNgTest( "5.13" );
129     }
130 
131     @Test public void test5131()
132         throws Exception
133     {
134         runTestNgTest( "5.13.1" );
135     }
136 
137     @Test public void test514()
138         throws Exception
139     {
140         runTestNgTest( "5.14", false ); // runOrder is not working
141     }
142 
143     @Test public void test5141()
144         throws Exception
145     {
146         runTestNgTest( "5.14.1" );
147     }
148 
149     @Test public void test5142()
150         throws Exception
151     {
152         runTestNgTest( "5.14.2" );
153     }
154 
155     @Test public void test60()
156         throws Exception
157     {
158         runTestNgTest( "6.0" );
159     }
160 
161     @Test public void test685()
162         throws Exception
163     {
164         runTestNgTest( "6.8.5" );
165     }
166 
167     public void runTestNgTest( String version )
168         throws Exception
169     {
170         runTestNgTest( version, true );
171     }
172 
173     public void runTestNgTest( String version, boolean validateRunOrder )
174         throws Exception
175     {
176 
177         final OutputValidator outputValidator = unpack( "testng-simple" ).resetInitialGoals( version ).executeTest();
178         outputValidator.verifyErrorFreeLog().assertTestSuiteResults( 3, 0, 0, 0 );
179 
180         if ( validateRunOrder )
181         {
182             // assert correct run order of tests
183             List<ReportTestSuite> report =
184                 HelperAssertions.extractReports( new File[] { outputValidator.getBaseDir() } );
185 
186             assertEquals( 3, report.size() );
187 
188             assertTrue( "TestNGSuiteTestC was executed first", getTestClass( report, 0 ).endsWith( "TestNGSuiteTestC" ) );
189             assertTrue( "TestNGSuiteTestB was executed second", getTestClass( report, 1 ).endsWith( "TestNGSuiteTestB" ) );
190             assertTrue( "TestNGSuiteTestA was executed last", getTestClass( report, 2 ).endsWith( "TestNGSuiteTestA" ) );
191         }
192     }
193 
194     private String getTestClass( List<ReportTestSuite> report, int i )
195     {
196         return report.get( i ).getFullClassName();
197     }
198 }