1 | |
package org.apache.maven.surefire.junit4; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import java.util.ArrayList; |
23 | |
import java.util.List; |
24 | |
import java.util.concurrent.atomic.AtomicInteger; |
25 | |
import org.apache.maven.surefire.report.ReportEntry; |
26 | |
import org.apache.maven.surefire.report.RunListener; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
public class MockReporter |
32 | |
implements RunListener |
33 | |
{ |
34 | 2 | private final List<String> events = new ArrayList<String>(); |
35 | |
|
36 | |
public static final String SET_STARTED = "SET_STARTED"; |
37 | |
|
38 | |
public static final String SET_COMPLETED = "SET_COMPLETED"; |
39 | |
|
40 | |
public static final String TEST_STARTED = "TEST_STARTED"; |
41 | |
|
42 | |
public static final String TEST_COMPLETED = "TEST_COMPLETED"; |
43 | |
|
44 | |
public static final String TEST_SKIPPED = "TEST_SKIPPED"; |
45 | |
|
46 | 2 | private final AtomicInteger testSucceeded = new AtomicInteger(); |
47 | |
|
48 | 2 | private final AtomicInteger testIgnored = new AtomicInteger(); |
49 | |
|
50 | 2 | private final AtomicInteger testFailed = new AtomicInteger(); |
51 | |
|
52 | 2 | private final AtomicInteger testError = new AtomicInteger(); |
53 | |
|
54 | |
public MockReporter() |
55 | 2 | { |
56 | 2 | } |
57 | |
|
58 | |
public void testSetStarting( ReportEntry report ) |
59 | |
{ |
60 | 0 | events.add( SET_STARTED ); |
61 | 0 | } |
62 | |
|
63 | |
public void testSetCompleted( ReportEntry report ) |
64 | |
{ |
65 | 0 | events.add( SET_COMPLETED ); |
66 | 0 | } |
67 | |
|
68 | |
public void testStarting( ReportEntry report ) |
69 | |
{ |
70 | 4 | events.add( TEST_STARTED ); |
71 | 4 | } |
72 | |
|
73 | |
public void testSucceeded( ReportEntry report ) |
74 | |
{ |
75 | 3 | events.add( TEST_COMPLETED ); |
76 | 3 | testSucceeded.incrementAndGet(); |
77 | |
|
78 | 3 | } |
79 | |
|
80 | |
public void testSkipped( ReportEntry report ) |
81 | |
{ |
82 | 0 | events.add( TEST_SKIPPED ); |
83 | 0 | testIgnored.incrementAndGet(); |
84 | 0 | } |
85 | |
|
86 | |
public int getTestSucceeded() |
87 | |
{ |
88 | 1 | return testSucceeded.get(); |
89 | |
} |
90 | |
|
91 | |
public int getTestFailed() |
92 | |
{ |
93 | 1 | return testFailed.get(); |
94 | |
} |
95 | |
|
96 | |
public void testError( ReportEntry report ) |
97 | |
{ |
98 | 0 | testError.incrementAndGet(); |
99 | 0 | } |
100 | |
|
101 | |
public void testFailed( ReportEntry report ) |
102 | |
{ |
103 | 1 | testFailed.incrementAndGet(); |
104 | 1 | } |
105 | |
|
106 | |
public void testAssumptionFailure( ReportEntry report ) |
107 | |
{ |
108 | 0 | } |
109 | |
|
110 | |
} |