-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestResult.java
More file actions
100 lines (89 loc) · 2.9 KB
/
Copy pathTestResult.java
File metadata and controls
100 lines (89 loc) · 2.9 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* Tracks the results of a single test.
* Tests may optionally report some message describing the test or the result.
* Each test is marked as having passed, failed, or caused an unexpected exception.
*/
public class TestResult {
// Constants for printing each type of test result
public static final String PASSED = "PASSED";
public static final String FAILED = "FAILED";
public static final String EXCEPTION = "EXCEPTION";
String type;
String description;
public TestResult(String result, String msg){
type = result;
description = msg;
}
/**
* Create a TestResult for a passed test. No message is provided.
* @return TestResult for a passed test
*/
public static TestResult createPassedResult() {
TestResult tResult = new TestResult(PASSED, "");
return tResult;
}
/**
* Create a TestResult for a passed test.
* @param msg Message describing the test result
* @return TestResult for a passed test
*/
public static TestResult createPassedResult(String msg) {
TestResult tResult = new TestResult(PASSED, msg);
return tResult;
}
/**
* Create a TestResult for a failed test. No message is provided.
* @return TestResult for a failed test
*/
public static TestResult createFailedResult() {
TestResult tResult = new TestResult(FAILED, "");
return tResult;
}
/**
* Create a TestResult for a failed test.
* @param msg Message describing the test result
* @return TestResult for a failed test
*/
public static TestResult createFailedResult(String msg) {
TestResult tResult = new TestResult(FAILED, msg);
return tResult;
}
/**
* Create a TestResult for a test with an unexpected exception. No message is provided.
* @return TestResult for an exception test
*/
public static TestResult createExceptionResult() {
TestResult tResult = new TestResult(EXCEPTION, "");
return tResult;
}
/**
* Create a TestResult for a test with an unexpected exception.
* @param msg Message describing the test result
* @return TestResult for an exception test
*/
public static TestResult createExceptionResult(String msg) {
TestResult tResult = new TestResult(EXCEPTION, msg);
return tResult;
}
/**
* Test for whether this is a passed test
* @return true if this is a passed test
*/
public boolean isPassed() {
return type.equals(PASSED);
}
/**
* Test for whether this is a failed test
* @return true if this is a failed test
*/
public boolean isFailed() {
return type.equals(FAILED);
}
/**
* Test for whether this is an exception test
* @return true if this is an exception test
*/
public boolean isException() {
return type.equals(EXCEPTION);
}
}