View Javadoc
1   package org.apache.maven.surefire.junit4;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
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   * Internal use only
30   */
31  public class MockReporter
32      implements RunListener
33  {
34      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      private final AtomicInteger testSucceeded = new AtomicInteger();
47  
48      private final AtomicInteger testIgnored = new AtomicInteger();
49  
50      private final AtomicInteger testFailed = new AtomicInteger();
51  
52      private final AtomicInteger testError = new AtomicInteger();
53  
54      public MockReporter()
55      {
56      }
57  
58      public void testSetStarting( ReportEntry report )
59      {
60          events.add( SET_STARTED );
61      }
62  
63      public void testSetCompleted( ReportEntry report )
64      {
65          events.add( SET_COMPLETED );
66      }
67  
68      public void testStarting( ReportEntry report )
69      {
70          events.add( TEST_STARTED );
71      }
72  
73      public void testSucceeded( ReportEntry report )
74      {
75          events.add( TEST_COMPLETED );
76          testSucceeded.incrementAndGet();
77  
78      }
79  
80      public void testSkipped( ReportEntry report )
81      {
82          events.add( TEST_SKIPPED );
83          testIgnored.incrementAndGet();
84      }
85  
86      public int getTestSucceeded()
87      {
88          return testSucceeded.get();
89      }
90  
91      public int getTestFailed()
92      {
93          return testFailed.get();
94      }
95  
96      public void testError( ReportEntry report )
97      {
98          testError.incrementAndGet();
99      }
100 
101     public void testFailed( ReportEntry report )
102     {
103         testFailed.incrementAndGet();
104     }
105 
106     public void testAssumptionFailure( ReportEntry report )
107     {
108     }
109 
110 }