-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestRunner.java
49 lines (34 loc) · 1.15 KB
/
TestRunner.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
48
49
import java.util.ArrayList;
import org.junit.runner.*;
import org.junit.runner.notification.*;
public class TestRunner {
public static void main(String[] args) {
ArrayList<Class> classesToTest = new ArrayList<Class>();
boolean anyFailures = false;
// ADD ANY MORE CLASSES YOU WISH TO TEST HERE
classesToTest.add(LaboonCoinTest.class);
// For all test classes added, loop through and use JUnit
// to run them.
for (Class c: classesToTest) {
Result r = JUnitCore.runClasses(c);
// Print out any failures for this class.
for (Failure f : r.getFailures()) {
System.out.println(f.toString());
}
// If r is not successful, there was at least one
// failure. Thus, set anyFailures to true - this
// can never be set back to false (no amount of
// successes will ever eclipse the fact that there
// was at least one failure.
if (!r.wasSuccessful()) {
anyFailures = true;
}
}
// After completion, notify user if all tests passed or any failed.
if (anyFailures) {
System.out.println("\n!!! - At least one failure, see above.");
} else {
System.out.println("\nALL TESTS PASSED");
}
}
}