-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRunner.java
43 lines (39 loc) · 1.27 KB
/
Runner.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
package test.util;
import test.*;
/**
* Runs tests and contains test helpers.
*/
public final class Runner {
public static void main(String[] args) {
new TestEnd() {
private int i = -1, passed = 0;
private Test[] tests = new Test[] {
/**
* List of tests to run.
* All the objects below should implement
* the interface Test.
*/
new SampleTest(),
new unitTest(),
new searchTest(),
};
public void run(Boolean success) {
i ++;
if (success != null && success) passed ++;
if (i == tests.length) {
// if any tests failed, report failure to the shell
// and the user
System.out.format(
"\n\u001b[%dm%d/%d Tests passed.\u001b[39m\n\n",
passed < tests.length ? 31 : 32,
passed,
tests.length
);
System.exit(passed < tests.length ? -1 : 0);
} else {
tests[i].run(this);
}
}
}.run(null);
}
}