1 package org.apache.maven.surefire.its.jiras;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.it.VerificationException;
23 import org.apache.maven.surefire.its.fixture.OutputValidator;
24 import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
25 import org.apache.maven.surefire.its.fixture.SurefireLauncher;
26 import org.junit.Test;
27
28 import static org.hamcrest.Matchers.containsString;
29 import static org.hamcrest.Matchers.is;
30 import static org.hamcrest.Matchers.startsWith;
31
32
33
34
35
36
37
38 public class Surefire1177TestngParallelSuitesIT
39 extends SurefireJUnit4IntegrationTestCase
40 {
41 private static final String EXPECTED_LINE = "TestNGSuiteTest#shouldRunAndPrintItself()";
42 private static final String UNEXPECTED_LINE = "ShouldNotRunTest#shouldNotRun()";
43
44 @Test
45 public void twoSuitesInParallel()
46 throws VerificationException
47 {
48 OutputValidator validator = unpack()
49 .forkMode( "never" )
50 .executeTest()
51 .verifyErrorFree( 2 );
52
53 validator.assertThatLogLine( startsWith( EXPECTED_LINE ), is( 2 ) );
54 validator.assertThatLogLine( is( EXPECTED_LINE + " 1." ), is( 1 ) );
55 validator.assertThatLogLine( is( EXPECTED_LINE + " 2." ), is( 1 ) );
56 validator.assertThatLogLine( containsString( UNEXPECTED_LINE ), is( 0 ) );
57 }
58
59 @Test
60 public void twoSuitesInParallelForked()
61 throws VerificationException
62 {
63 OutputValidator validator = unpack()
64 .forkMode( "once" )
65 .executeTest()
66 .verifyErrorFree( 2 );
67
68 validator.assertThatLogLine( startsWith( EXPECTED_LINE ), is( 2 ) );
69 validator.assertThatLogLine( is( EXPECTED_LINE + " 1." ), is( 1 ) );
70 validator.assertThatLogLine( is( EXPECTED_LINE + " 2." ), is( 1 ) );
71 validator.assertThatLogLine( containsString( UNEXPECTED_LINE ), is( 0 ) );
72 }
73
74 private SurefireLauncher unpack()
75 {
76 return unpack( "testng-parallel-suites" );
77 }
78 }