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 org.apache.maven.surefire.report.RunListener;
23 import org.apache.maven.surefire.report.ReportEntry;
24 import org.apache.maven.surefire.report.ReporterConfiguration;
25 import org.apache.maven.surefire.report.ReporterException;
26
27 import java.util.ArrayList;
28 import java.util.List;
29 import java.util.concurrent.atomic.AtomicInteger;
30
31
32 public class MockReporter
33 implements RunListener
34 {
35 private final List<String> events = new ArrayList<String>();
36
37 public static final String RUN_STARTED = "RUN_STARTED";
38
39 public static final String RUN_COMPLETED = "RUN_COMPLETED";
40
41 public static final String SET_STARTED = "SET_STARTED";
42
43 public static final String SET_COMPLETED = "SET_COMPLETED";
44
45 public static final String TEST_STARTED = "TEST_STARTED";
46
47 public static final String TEST_COMPLETED = "TEST_COMPLETED";
48
49 public static final String TEST_FAILED = "TEST_FAILED";
50
51 public static final String TEST_ERROR = "TEST_ERROR";
52
53 public static final String TEST_SKIPPED = "TEST_SKIPPED";
54
55 private final AtomicInteger testSucceeded = new AtomicInteger();
56
57 private final AtomicInteger testIgnored = new AtomicInteger();
58
59 private final AtomicInteger testFailed = new AtomicInteger();
60
61 private final AtomicInteger testError = new AtomicInteger();
62
63 public MockReporter()
64 {
65 }
66
67 public MockReporter( ReporterConfiguration reporterConfiguration )
68 {
69
70 }
71
72 public void runStarting()
73 {
74 events.add( RUN_STARTED );
75 }
76
77 public void runCompleted()
78 {
79 events.add( RUN_COMPLETED );
80 }
81
82 public void testSetStarting( ReportEntry report )
83 throws ReporterException
84 {
85 events.add( SET_STARTED );
86 }
87
88 public void testSetCompleted( ReportEntry report )
89 throws ReporterException
90 {
91 events.add( SET_COMPLETED );
92 }
93
94 public void testStarting( ReportEntry report )
95 {
96 events.add( TEST_STARTED );
97 }
98
99 public void testSucceeded( ReportEntry report )
100 {
101 events.add( TEST_COMPLETED );
102 testSucceeded.incrementAndGet();
103
104 }
105
106 public void testSkipped( ReportEntry report )
107 {
108 events.add( TEST_SKIPPED );
109 testIgnored.incrementAndGet();
110 }
111
112 public void writeFooter( String footer )
113 {
114 }
115
116 public void writeDetailMessage( String message )
117 {
118 }
119
120 public List<String> getEvents()
121 {
122 return events;
123 }
124
125 public int getTestSucceeded()
126 {
127 return testSucceeded.get();
128 }
129
130 public int getTestIgnored()
131 {
132 return testIgnored.get();
133 }
134
135 public int getTestFailed()
136 {
137 return testFailed.get();
138 }
139
140 public void writeConsoleMessage( String message )
141 {
142 }
143
144 public void testError( ReportEntry report )
145 {
146 }
147
148 public void testFailed( ReportEntry report )
149 {
150 }
151
152 public void testAssumptionFailure( ReportEntry report )
153 {
154 }
155 }