1 | |
package org.apache.maven.surefire.report; |
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.suite.RunResult; |
23 | |
|
24 | |
import java.util.Properties; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | 0 | public class TestSetStatistics |
34 | |
{ |
35 | |
private static final String RESULTS_ERRORS = "errors"; |
36 | |
|
37 | |
private static final String RESULTS_COMPLETED_COUNT = "completedCount"; |
38 | |
|
39 | |
private static final String RESULTS_FAILURES = "failures"; |
40 | |
|
41 | |
private static final String RESULTS_SKIPPED = "skipped"; |
42 | |
|
43 | |
|
44 | |
private int completedCount; |
45 | |
|
46 | |
private int errors; |
47 | |
|
48 | |
private int failures; |
49 | |
|
50 | |
private int skipped; |
51 | |
|
52 | |
public synchronized void incrementCompletedCount() |
53 | |
{ |
54 | 0 | completedCount += 1; |
55 | 0 | } |
56 | |
|
57 | |
public synchronized void incrementErrorsCount() |
58 | |
{ |
59 | 0 | errors += 1; |
60 | 0 | } |
61 | |
|
62 | |
public synchronized void incrementFailureCount() |
63 | |
{ |
64 | 0 | failures += 1; |
65 | 0 | } |
66 | |
|
67 | |
public synchronized void incrementSkippedCount() |
68 | |
{ |
69 | 0 | skipped += 1; |
70 | 0 | } |
71 | |
|
72 | |
public synchronized boolean hadFailures() |
73 | |
{ |
74 | 0 | return failures > 0; |
75 | |
} |
76 | |
|
77 | |
public synchronized boolean hadErrors() |
78 | |
{ |
79 | 0 | return errors > 0; |
80 | |
} |
81 | |
|
82 | |
public synchronized int getCompletedCount() |
83 | |
{ |
84 | 0 | return completedCount; |
85 | |
} |
86 | |
|
87 | |
public int getSkipped() |
88 | |
{ |
89 | 0 | return skipped; |
90 | |
} |
91 | |
|
92 | |
public synchronized void initResultsFromProperties( Properties results ) |
93 | |
{ |
94 | 0 | errors = Integer.valueOf( results.getProperty( RESULTS_ERRORS, "0" ) ).intValue(); |
95 | 0 | skipped = Integer.valueOf( results.getProperty( RESULTS_SKIPPED, "0" ) ).intValue(); |
96 | 0 | failures = Integer.valueOf( results.getProperty( RESULTS_FAILURES, "0" ) ).intValue(); |
97 | 0 | completedCount = Integer.valueOf( results.getProperty( RESULTS_COMPLETED_COUNT, "0" ) ).intValue(); |
98 | 0 | } |
99 | |
|
100 | |
|
101 | |
public synchronized RunResult getRunResult() |
102 | |
{ |
103 | 0 | return new RunResult( completedCount, errors, failures, skipped ); |
104 | |
} |
105 | |
|
106 | |
public synchronized String getSummary() |
107 | |
{ |
108 | 0 | return "Tests run: " + completedCount + ", Failures: " + failures + ", Errors: " + errors + ", Skipped: " |
109 | |
+ skipped; |
110 | |
} |
111 | |
|
112 | |
} |