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.it.VerificationException;
23 import org.apache.maven.it.Verifier;
24 import org.apache.maven.it.util.ResourceExtractor;
25 import org.apache.maven.surefire.its.misc.HelperAssertions;
26
27 import java.io.File;
28 import java.io.IOException;
29 import java.util.ArrayList;
30 import java.util.Arrays;
31 import java.util.List;
32
33
34
35
36
37
38
39 public class ResultCountingIT
40 extends AbstractSurefireIntegrationTestClass
41 {
42 public void testCountingWithJunit481ForkNever()
43 throws Exception
44 {
45 assertForkMode( "never" );
46 }
47
48 public void testCountingWithJunit481ForkOnce()
49 throws Exception
50 {
51 assertForkMode( "once" );
52 }
53
54
55 public void testCountingWithJunit481ForkAlways()
56 throws Exception
57 {
58 assertForkMode( "always" );
59 }
60
61 private void assertForkMode( String forkMode )
62 throws IOException, VerificationException
63 {
64 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/result-counting" );
65
66 Verifier verifier = new Verifier( testDir.getAbsolutePath() );
67 String[] opts = { "-fn" };
68 verifier.setCliOptions( new ArrayList<String>( Arrays.asList( opts ) ) );
69 List<String> goals = getGoals( forkMode );
70 this.executeGoals( verifier, goals );
71
72 verifier.resetStreams();
73
74 HelperAssertions.assertTestSuiteResults( 36, 23, 4, 2, testDir );
75
76 verifier.verifyTextInLog( "Tests run: 36, Failures: 4, Errors: 23, Skipped: 2" );
77 }
78
79 private List<String> getGoals( String forkMode )
80 {
81 List<String> goals = this.getInitialGoals();
82 goals.add( "test" );
83 goals.add( "-DforkMode=" + forkMode );
84 return goals;
85 }
86 }