This repository has been archived by the owner on Feb 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReport.java
47 lines (43 loc) · 1.66 KB
/
Report.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// Copyright 2016, Yahoo Inc.
// Copyrights licensed under the New BSD License.
// See the accompanying LICENSE file for terms.
//
package github.com.jminusminus.simplebdd;
class Report {
protected String ok = "✓";
protected String err = "✖";
protected String colorNormal = "\033[0m";
protected String colorTitled = "\033[37m";
protected String colorReport = "\033[90m";
protected String colorPassed = "\033[92m";
protected String colorFailed = "\033[31m";
Report(String name, Result[] results) {
int total = results.length;
int failures = 0;
System.out.println("\n" + this.colorReport + name + "\n");
for (int i = 0; i < total; i++) {
Result r = results[i];
if (r.failed) {
failures++;
String msg = this.colorFailed;
msg += this.err + " should " + r.should + ", expected [" + r.expected + "], got [" + r.got + "]";
msg += this.colorReport;
System.out.println("\t" + msg);
} else {
System.out.println("\t" + this.colorPassed + this.ok + this.colorReport + " should " + r.should);
}
}
String status;
if (failures == 0) {
status = this.colorPassed + this.ok + this.colorReport;
} else {
status = this.colorFailed + this.err + this.colorReport;
}
System.out.print("\n" + status + " " + Integer.toString(total) + " tests complete");
if (failures > 0) {
System.out.print(", " + Integer.toString(failures) + " failures");
}
System.out.println(this.colorNormal + "\n");
}
}