|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object PIRL.Utilities.Checker
public class Checker
A Checker is used to compare expected against obtained results for unit testing.
A set of Check methods compares an expected argument value with an obtained argument value for equality. When the arguments match the word "PASS" is printed, otherwise the word "FAIL" is printed. This is followed by ": " and the description String that very briefly identifies what was checked (i.e. the unit test that occured). The obtained value will then be printed following " - " if the Show_Obtained flag is enabled. If the comparison does not match, or the Check is Verbose, the expected and obtained arguments are printed on the next two lines following an "====> expected: " and "====> obtained: " prefix.
Check methods are provided for integer, floating point, boolean and char values as well as String and generic Object values. String values are printed enclosed in double quotes (") and char values are listed enclosed in single quotes (').
The total number of checks performed (Checks_Total), and the number in which the comparison matched (Checks_Passed), is accumulated by each Check method.
Field Summary | |
---|---|
int |
Checks_Passed
Total number of Checks where expected matched obtained. |
int |
Checks_Total
Total number of Checks performed. |
static String |
ID
|
boolean |
Show_Obtained
Set to true to always show the obtained value. |
boolean |
Verbose
Set to true to always show both the expected and obtained values. |
Constructor Summary | |
---|---|
Checker()
|
Method Summary | |
---|---|
boolean |
Check(boolean passed)
Updates the check accounting. |
boolean |
Check(String description,
boolean expected,
boolean obtained)
Checks boolean values. |
boolean |
Check(String description,
char expected,
char obtained)
Checks char values. |
boolean |
Check(String description,
double expected,
double obtained)
Checks floating point values. |
boolean |
Check(String description,
Exception expected,
Exception obtained)
Checks Exceptions. |
boolean |
Check(String description,
long expected,
long obtained)
Checks integer values. |
boolean |
Check(String description,
Object expected,
Object obtained)
Checks Objects. |
boolean |
Check(String description,
String expected,
String obtained)
Checks String values. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ID
public int Checks_Total
public int Checks_Passed
public boolean Verbose
Default is false;
public boolean Show_Obtained
Default is false;
Constructor Detail |
---|
public Checker()
Method Detail |
---|
public boolean Check(String description, long expected, long obtained)
description
- A brief description of what was checked.expected
- The expected value.obtained
- The obtained value.
public boolean Check(String description, double expected, double obtained)
description
- A brief description of what was checked.expected
- The expected value.obtained
- The obtained value.
public boolean Check(String description, boolean expected, boolean obtained)
description
- A brief description of what was checked.expected
- The expected value.obtained
- The obtained value.
public boolean Check(String description, char expected, char obtained)
description
- A brief description of what was checked.expected
- The expected value.obtained
- The obtained value.
public boolean Check(String description, String expected, String obtained)
description
- A brief description of what was checked.expected
- The expected value.obtained
- The obtained value.
public boolean Check(String description, Exception expected, Exception obtained)
If both the excpected and obtained exception are null they are
equal. If both are non-null the class
of
each are checked for equality. If only one exception is null they are
not equal.
description
- A brief description of what was checked.expected
- The expected Exception.obtained
- The obtained Exception.
public boolean Check(String description, Object expected, Object obtained)
If both objects are null they are equal. N.B.: The Object.equals(Object)
method is used to compare a non-null expected
Object with the obtained object, which may not be what is expected
since this comparison is only true if both arguments are the same
Object reference.
description
- A brief description of what was checked.expected
- The expected Object.obtained
- The obtained Object.
public boolean Check(boolean passed)
The Checks_Total accumulator is incremented. The Checks_Passed accumulator is incremented if passed is true.
passed
- true if the external test passed; false otherwise.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |