1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugin.surefire.runorder;
20
21 import java.io.File;
22 import java.io.IOException;
23
24 import org.apache.maven.surefire.api.report.ReportEntry;
25 import org.apache.maven.surefire.api.runorder.RunEntryStatisticsMap;
26
27 import static org.apache.maven.surefire.api.runorder.RunEntryStatisticsMap.fromFile;
28
29
30
31
32 public class StatisticsReporter {
33 private final RunEntryStatisticsMap existing;
34
35 private final RunEntryStatisticsMap newResults;
36
37 private final File dataFile;
38
39 public StatisticsReporter(File dataFile) {
40 this(dataFile, fromFile(dataFile), new RunEntryStatisticsMap());
41 }
42
43 protected StatisticsReporter(File dataFile, RunEntryStatisticsMap existing, RunEntryStatisticsMap newResults) {
44 this.dataFile = dataFile;
45 this.existing = existing;
46 this.newResults = newResults;
47 }
48
49 public synchronized void testSetCompleted() {
50 try {
51 newResults.serialize(dataFile);
52 } catch (IOException e) {
53 throw new RuntimeException(e);
54 }
55 }
56
57 public void testSucceeded(ReportEntry report) {
58 newResults.add(existing.createNextGeneration(report));
59 }
60
61 public void testSkipped(ReportEntry report) {
62 newResults.add(existing.createNextGeneration(report));
63 }
64
65 public void testError(ReportEntry report) {
66 newResults.add(existing.createNextGenerationFailure(report));
67 }
68
69 public void testFailed(ReportEntry report) {
70 newResults.add(existing.createNextGenerationFailure(report));
71 }
72 }