1 package org.apache.maven.surefire.its;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.List;
23
24 import org.apache.maven.plugins.surefire.report.ReportTestSuite;
25 import org.apache.maven.surefire.its.fixture.HelperAssertions;
26 import org.apache.maven.surefire.its.fixture.OutputValidator;
27 import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
28 import org.apache.maven.surefire.its.fixture.SurefireLauncher;
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
37
38
39
40
41
42
43 public class CheckTestNgVersionsIT
44 extends SurefireJUnit4IntegrationTestCase
45 {
46
47 @Test public void test47()
48 throws Exception
49 {
50 runTestNgTest( "4.7", "jdk15" );
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", "jdk15" );
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", "jdk15" );
63 }
64
65 @Test public void test502()
66 throws Exception
67 {
68 runTestNgTest( "5.0.2", "jdk15" );
69 }
70
71 @Test public void test51()
72 throws Exception
73 {
74 runTestNgTest( "5.1", "jdk15" );
75 }
76
77 @Test public void test55()
78 throws Exception
79 {
80 runTestNgTest( "5.5", "jdk15" );
81 }
82
83 @Test public void test56()
84 throws Exception
85 {
86 runTestNgTest( "5.6", "jdk15" );
87 }
88
89 @Test public void test57()
90 throws Exception
91 {
92 runTestNgTest( "5.7", "jdk15" );
93 }
94
95 @Test public void test58()
96 throws Exception
97 {
98 runTestNgTest( "5.8", "jdk15" );
99 }
100
101 @Test public void test59()
102 throws Exception
103 {
104 runTestNgTest( "5.9", "jdk15" );
105 }
106
107 @Test public void test510()
108 throws Exception
109 {
110 runTestNgTest( "5.10", "jdk15" );
111 }
112
113 @Test public void test511()
114 throws Exception
115 {
116 runTestNgTest( "5.11", "jdk15" );
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" );
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 runTestNgTestWithRunOrder( "6.8.5" );
165 }
166
167 private void runTestNgTestWithRunOrder( String version )
168 throws Exception
169 {
170 runTestNgTest( version, null, true );
171 }
172
173 private void runTestNgTest( String version )
174 throws Exception
175 {
176 runTestNgTest( version, null, false );
177 }
178
179 private void runTestNgTest( String version, boolean validateRunOrder )
180 throws Exception
181 {
182 runTestNgTest( version, null, validateRunOrder );
183 }
184
185 private void runTestNgTest( String version, String classifier )
186 throws Exception
187 {
188 runTestNgTest( version, classifier, false );
189 }
190
191 private void runTestNgTest( String version, String classifier, boolean validateRunOrder )
192 throws Exception
193 {
194 final SurefireLauncher launcher = unpack( "testng-simple" )
195 .sysProp( "testNgVersion", version );
196
197 if ( classifier != null )
198 {
199 launcher.sysProp( "testNgClassifier", classifier );
200 }
201
202 final OutputValidator outputValidator = launcher.executeTest();
203
204 outputValidator.verifyErrorFreeLog().assertTestSuiteResults( 3, 0, 0, 0 );
205
206 if ( validateRunOrder )
207 {
208
209 List<ReportTestSuite> report = HelperAssertions.extractReports( outputValidator.getBaseDir() );
210
211 assertEquals( 3, report.size() );
212
213 assertTrue( "TestNGSuiteTestC was executed first", getTestClass( report, 0 ).endsWith( "TestNGSuiteTestC" ) );
214 assertTrue( "TestNGSuiteTestB was executed second", getTestClass( report, 1 ).endsWith( "TestNGSuiteTestB" ) );
215 assertTrue( "TestNGSuiteTestA was executed last", getTestClass( report, 2 ).endsWith( "TestNGSuiteTestA" ) );
216 }
217 }
218
219 private String getTestClass( List<ReportTestSuite> report, int i )
220 {
221 return report.get( i ).getFullClassName();
222 }
223 }