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.plugin.surefire.report.TestSetStats;
23 import org.apache.maven.surefire.suite.RunResult;
24
25
26
27
28 public class RunStatistics
29 {
30 private int completedCount;
31
32 private int errors;
33
34 private int failures;
35
36 private int skipped;
37
38 private int flakes;
39
40 public RunStatistics()
41 {
42 }
43
44 public synchronized boolean hadFailures()
45 {
46 return failures > 0;
47 }
48
49 public synchronized boolean hadErrors()
50 {
51 return errors > 0;
52 }
53
54 public synchronized int getCompletedCount()
55 {
56 return completedCount;
57 }
58
59 public synchronized int getSkipped()
60 {
61 return skipped;
62 }
63
64 public synchronized int getFailures()
65 {
66 return failures;
67 }
68
69 public synchronized int getErrors()
70 {
71 return errors;
72 }
73
74 public synchronized int getFlakes()
75 {
76 return flakes;
77 }
78
79 public synchronized void add( TestSetStats testSetStats )
80 {
81 this.completedCount += testSetStats.getCompletedCount();
82 this.errors += testSetStats.getErrors();
83 this.failures += testSetStats.getFailures();
84 this.skipped += testSetStats.getSkipped();
85 }
86
87 public synchronized void set( int completedCount, int errors, int failures, int skipped, int flakes )
88 {
89 this.completedCount = completedCount;
90 this.errors = errors;
91 this.failures = failures;
92 this.skipped = skipped;
93 this.flakes = flakes;
94 }
95
96 public synchronized RunResult getRunResult()
97 {
98 return new RunResult( completedCount, errors, failures, skipped, flakes );
99 }
100
101 public synchronized String getSummary()
102 {
103 String summary =
104 "Tests run: " + completedCount + ", Failures: " + failures + ", Errors: " + errors + ", Skipped: "
105 + skipped;
106 if ( flakes > 0 )
107 {
108 summary += ", Flakes: " + flakes;
109 }
110 return summary;
111 }
112 }