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 org.apache.maven.surefire.its.fixture.MavenLauncher;
23 import org.apache.maven.surefire.its.fixture.OutputValidator;
24 import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.junit.runners.Parameterized;
28
29 import java.util.HashMap;
30 import java.util.Map;
31
32 import static org.junit.runners.Parameterized.Parameter;
33
34
35
36
37
38
39
40 @RunWith( Parameterized.class )
41 public abstract class AbstractFailFastIT
42 extends SurefireJUnit4IntegrationTestCase
43 {
44 @Parameter( 0 )
45 public String description;
46
47 @Parameter( 1 )
48 public String profile;
49
50 @Parameter( 2 )
51 public Map<String, String> properties;
52
53 @Parameter( 3 )
54 public int total;
55
56 @Parameter( 4 )
57 public int failures;
58
59 @Parameter( 5 )
60 public int errors;
61
62 @Parameter( 6 )
63 public int skipped;
64
65 protected abstract String withProvider();
66
67 protected final OutputValidator prepare( String description, String profile, Map<String, String> properties )
68 {
69 MavenLauncher launcher = unpack( "/fail-fast-" + withProvider(), "_" + description )
70 .maven();
71
72 if ( profile != null )
73 {
74 launcher.addGoal( "-P " + profile );
75 }
76
77 if ( failures != 0 || errors != 0 )
78 {
79 launcher.withFailure();
80 }
81
82 return launcher.sysProp( properties ).executeTest();
83 }
84
85 protected final OutputValidator prepare( String description, Map<String, String> properties )
86 {
87 return prepare( description, null, properties );
88 }
89
90 protected static Map<String, String> props( int forkCount, int skipAfterFailureCount, boolean reuseForks )
91 {
92 Map<String, String> props = new HashMap<String, String>( 3 );
93 props.put( "surefire.skipAfterFailureCount", "" + skipAfterFailureCount );
94 props.put( "forkCount", "" + forkCount );
95 props.put( "reuseForks", "" + reuseForks );
96 return props;
97 }
98
99 @Test
100 public void test()
101 {
102 prepare( description, profile, properties )
103 .assertTestSuiteResults( total, errors, failures, skipped );
104 }
105 }