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 synchronized boolean hadFailures()
41 {
42 return failures > 0;
43 }
44
45 public synchronized boolean hadErrors()
46 {
47 return errors > 0;
48 }
49
50 public synchronized int getCompletedCount()
51 {
52 return completedCount;
53 }
54
55 public synchronized int getSkipped()
56 {
57 return skipped;
58 }
59
60 public synchronized int getFailures()
61 {
62 return failures;
63 }
64
65 public synchronized int getErrors()
66 {
67 return errors;
68 }
69
70 public synchronized int getFlakes()
71 {
72 return flakes;
73 }
74
75 public synchronized void add( TestSetStats testSetStats )
76 {
77 this.completedCount += testSetStats.getCompletedCount();
78 this.errors += testSetStats.getErrors();
79 this.failures += testSetStats.getFailures();
80 this.skipped += testSetStats.getSkipped();
81 }
82
83 public synchronized void set( int completedCount, int errors, int failures, int skipped, int flakes )
84 {
85 this.completedCount = completedCount;
86 this.errors = errors;
87 this.failures = failures;
88 this.skipped = skipped;
89 this.flakes = flakes;
90 }
91
92 public synchronized RunResult getRunResult()
93 {
94 return new RunResult( completedCount, errors, failures, skipped, flakes );
95 }
96
97 public synchronized String getSummary()
98 {
99 String summary =
100 "Tests run: " + completedCount + ", Failures: " + failures + ", Errors: " + errors + ", Skipped: "
101 + skipped;
102 if ( flakes > 0 )
103 {
104 summary += ", Flakes: " + flakes;
105 }
106 return summary;
107 }
108 }