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 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 completedCount += 1;
55 }
56
57 public synchronized void incrementErrorsCount()
58 {
59 errors += 1;
60 }
61
62 public synchronized void incrementFailureCount()
63 {
64 failures += 1;
65 }
66
67 public synchronized void incrementSkippedCount()
68 {
69 skipped += 1;
70 }
71
72 public synchronized boolean hadFailures()
73 {
74 return failures > 0;
75 }
76
77 public synchronized boolean hadErrors()
78 {
79 return errors > 0;
80 }
81
82 public synchronized int getCompletedCount()
83 {
84 return completedCount;
85 }
86
87 public int getSkipped()
88 {
89 return skipped;
90 }
91
92 public synchronized void initResultsFromProperties( Properties results )
93 {
94 errors = Integer.valueOf( results.getProperty( RESULTS_ERRORS, "0" ) ).intValue();
95 skipped = Integer.valueOf( results.getProperty( RESULTS_SKIPPED, "0" ) ).intValue();
96 failures = Integer.valueOf( results.getProperty( RESULTS_FAILURES, "0" ) ).intValue();
97 completedCount = Integer.valueOf( results.getProperty( RESULTS_COMPLETED_COUNT, "0" ) ).intValue();
98 }
99
100
101 public synchronized RunResult getRunResult()
102 {
103 return new RunResult( completedCount, errors, failures, skipped );
104 }
105
106 public synchronized String getSummary()
107 {
108 return "Tests run: " + completedCount + ", Failures: " + failures + ", Errors: " + errors + ", Skipped: "
109 + skipped;
110 }
111
112 }