|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttester.Tester
public class Tester
A test harness that compares arbitrary objects for extensional equality.
It catches exceptions in tests - the remaining tests are omitted.
It uses the visitor pattern to accept test cases.
Displays the data even if no tests are present.
Field Summary | |
---|---|
protected int |
errors
the total number of errors |
protected StringBuilder |
failedResults
A String that records the results for all failed tests |
protected StringBuilder |
fullTestResults
A String that records all test results |
protected int |
numberOfTests
the total number of tests |
protected String |
testname
the name of the current test |
protected int |
warnings
the total number of warnings of inexact comparisons |
Constructor Summary | |
---|---|
Tester()
start with no tests and no failures |
Method Summary | ||
---|---|---|
|
checkConstructorException(Exception e,
String className,
Object... args)
Test that verifies that when the constructor for the given class is invoked with the given arguments, it throws the expected exception with the expected message. |
|
|
checkConstructorException(String testname,
Exception e,
String className,
Object... args)
Test that verifies that when the constructor for the given class is invoked with the given arguments, it throws the expected exception with the expected message. |
|
|
checkEquivalent(T obj1,
T obj2,
Equivalence<T> equiv)
Use the given
function object to determine the equivalence
of the two given objects. |
|
|
checkEquivalent(T obj1,
T obj2,
Equivalence<T> equiv,
String testname)
Use the given
function object to determine the equivalence
of the two given objects. |
|
|
checkException(Exception e,
T object,
String method,
Object... args)
Test that verifies that when the given object invokes the given method with the given arguments, it throws the expected exception with the expected message. |
|
|
checkException(String testname,
Exception e,
T object,
String method,
Object... args)
Test that verifies that when the given object invokes the given method with the given arguments, it throws the expected exception with the expected message. |
|
boolean |
checkExpect(boolean result)
Test that only reports success or failure |
|
boolean |
checkExpect(boolean result,
String testname)
Test that only reports success or failure |
|
|
checkExpect(T actual,
T expected)
Test that compares two objects of any kind -- exact values only |
|
|
checkExpect(T actual,
T expected,
String testname)
Test that compares two objects of any kind -- exact values only |
|
boolean |
checkFail(boolean result)
Test that only reports success or failure |
|
boolean |
checkFail(boolean result,
String testname)
Test that only reports success or failure |
|
|
checkFail(T actual,
T expected)
Test that compares two objects of any kind and is expected to fail: comparison failure constitutes a successful test. |
|
|
checkFail(T actual,
T expected,
String testname)
Test that compares two objects of any kind and is expected to fail: comparison failure constitutes a successful test. |
|
|
checkInequivalent(T obj1,
T obj2,
Equivalence<T> equiv)
Use the given
function object to determine the NON-equivalence
of the two given objects. |
|
|
checkInequivalent(T obj1,
T obj2,
Equivalence<T> equiv,
String testname)
Use the given
function object to determine the equivalence
of the two given objects. |
|
|
checkInexact(T actual,
T expected,
double tolerance)
Test that compares two objects of any kind. |
|
|
checkInexact(T actual,
T expected,
double tolerance,
String testname)
Test that compares two objects of any kind. |
|
|
checkInexactFail(T actual,
T expected,
double tolerance)
Test that compares two objects of any kind and is expected to fail: comparison failure constitutes a successful test. |
|
|
checkInexactFail(T actual,
T expected,
double tolerance,
String testname)
Test that compares two objects of any kind and is expected to fail: comparison failure constitutes a successful test. |
|
|
checkInexactIterable(Iterable<T> actual,
Iterable<T> expected,
double tolerance)
Test that compares two objects that implement Iterable
interface by traversing over the data. |
|
|
checkInexactIterable(Iterable<T> actual,
Iterable<T> expected,
double tolerance,
String testname)
Test that compares two objects that implement Iterable
interface by traversing over the data. |
|
|
checkInexactMethod(Object expected,
double tolerance,
T object,
String method,
Object... args)
Invoke the method with the given name on a given object with the given arguments - check if it produces the expected value |
|
|
checkInexactMethod(String testname,
Object expected,
double tolerance,
T object,
String method,
Object... args)
Invoke the method with the given name on a given object with the given arguments - check if it produces the expected value |
|
|
checkInexactNoneOf(double tolerance,
T actual,
T... expected)
Test that determines whether the value of the given object (of any kind) is not equal to any of the expected results |
|
|
checkInexactNoneOf(String testname,
double tolerance,
T actual,
T... expected)
Test that determines whether the value of the given object (of any kind) is not equal to any of the expected results |
|
|
checkInexactOneOf(double tolerance,
T actual,
T... expected)
Test that determines whether the value of the given object (of any kind) is the same as one of the expected results |
|
|
checkInexactOneOf(String testname,
double tolerance,
T actual,
T... expected)
Test that determines whether the value of the given object (of any kind) is the same as one of the expected results |
|
|
checkInexactTraversal(Traversal<T> actual,
Traversal<T> expected,
double tolerance)
Test that compares two objects that implement Traversal interface by traversing over the data. |
|
|
checkInexactTraversal(Traversal<T> actual,
Traversal<T> expected,
double tolerance,
String testname)
Test that compares two objects that implement Traversal interface by traversing over the data. |
|
|
checkIterable(Iterable<T> actual,
Iterable<T> expected)
Test that compares two objects that implement Iterable
interface by traversing over the data -- objects must be composed of
exact values only |
|
|
checkIterable(Iterable<T> actual,
Iterable<T> expected,
String testname)
Test that compares two objects that implement Iterable
interface by traversing over the data -- objects must be composed of
exact values only |
|
|
checkMethod(Object expected,
T object,
String method,
Object... args)
Invoke the method with the given name on a given object with the given arguments - check if it produces the expected result |
|
|
checkMethod(String testname,
Object expected,
T object,
String method,
Object... args)
Invoke the method with the given name on a given object with the given arguments - check if it produces the expected result |
|
|
checkNoneOf(String testname,
T actual,
T... expected)
Test that determines whether the value of the given object (of any kind) is not equal to any of the expected results |
|
|
checkNoneOf(T actual,
T... expected)
Test that determines whether the value of the given object (of any kind) is not equal to any of the expected results |
|
|
checkNumRange(Number actual,
Number low,
Number high)
Test that determines whether the value of the given numerical object (of any kind) is the range between low (inclusive) and high (exclusive) values. |
|
|
checkNumRange(Number actual,
Number low,
Number high,
boolean lowIncl,
boolean highIncl)
Test that determines whether the value of the given object (of any kind) is the range between low and high values. |
|
|
checkNumRange(Number actual,
Number low,
Number high,
boolean lowIncl,
boolean highIncl,
String testname)
Test that determines whether the value of the given object (of any kind) is the range between low and high values. |
|
|
checkNumRange(Number actual,
Number low,
Number high,
String testname)
Test that determines whether the value of the given numerical object (of any kind) is the range between low (inclusive) and high (exclusive) values. |
|
|
checkOneOf(String testname,
T actual,
T... expected)
Test that determines whether the value of the given object (of any kind) is the same as one of the expected results |
|
|
checkOneOf(T actual,
T... expected)
Test that determines whether the value of the given object (of any kind) is the same as one of the expected results |
|
|
checkRange(Comparable<T> actual,
T low,
T high)
Test that determines whether the value of the given object (of any kind) is the range between low (inclusive) and high (exclusive) values |
|
|
checkRange(Comparable<T> actual,
T low,
T high,
boolean lowIncl,
boolean highIncl)
Test that determines whether the value of the given object (of any kind) is the range between low and high values. |
|
|
checkRange(Comparable<T> actual,
T low,
T high,
boolean lowIncl,
boolean highIncl,
String testname)
Test that determines whether the value of the given object (of any kind) is the range between low and high values. |
|
|
checkRange(Comparable<T> actual,
T low,
T high,
String testname)
Test that determines whether the value of the given object (of any kind) is the range between low (inclusive) and high (exclusive) values |
|
|
checkRange(T actual,
T low,
T high,
boolean lowIncl,
boolean highIncl,
Comparator<T> comp)
Test that determines whether the value of the given object (of any kind) is the range between low (inclusive) and high (exclusive) values |
|
|
checkRange(T actual,
T low,
T high,
boolean lowIncl,
boolean highIncl,
Comparator<T> comp,
String testname)
Test that determines whether the value of the given object (of any kind) is the range between low (inclusive) and high (exclusive) values |
|
|
checkRange(T actual,
T low,
T high,
Comparator<T> comp)
Test that determines whether the value of the given object (of any kind) is the range between low (inclusive) and high (exclusive) values |
|
|
checkRange(T actual,
T low,
T high,
Comparator<T> comp,
String testname)
Test that determines whether the value of the given object (of any kind) is the range between low (inclusive) and high (exclusive) values |
|
|
checkSet(Set<T> actual,
Set<T> expected)
Test that compares two objects that implement Set
interface by comparing data using the equals method for
comparing the elements of the two sets. |
|
|
checkSet(Set<T> actual,
Set<T> expected,
String testname)
Test that compares two objects that implement Set
interface by comparing data using the equals method for
comparing the elements of the two sets. |
|
|
checkTraversal(Traversal<T> actual,
Traversal<T> expected)
Test that compares two objects that implement Traversal
interface by traversing over the data -- objects must be composed of
exact values only |
|
|
checkTraversal(Traversal<T> actual,
Traversal<T> expected,
String testname)
Test that compares two objects that implement Traversal
interface by traversing over the data -- objects must be composed of
exact values only |
|
protected void |
done(boolean failed)
If the test evaluation terminated due to an exception, report the test that threw the exception.. |
|
boolean |
fail()
Test nothing, just report failure. |
|
boolean |
fail(String testname)
Test nothing, just report failure. |
|
protected void |
fullTestReport()
Produce test names and values compared for all tests |
|
static boolean |
run(Object obj)
A hook to run the tester for any object --- needed to run from BlueJ. |
|
protected void |
runAnyTests(Object f)
Find all test methods in the class of the given object; run tests and report results. |
|
protected void |
runAnyTests(Object f,
boolean full)
Find all test methods in the class of the given object; run tests and report results. |
|
protected void |
runAnyTests(Object f,
boolean full,
boolean printall)
Find all test methods in the class of the given object; run tests and report results. |
|
static boolean |
runFullReport(Object... objs)
A hook to run the tester for a collection of objects and produce a full test report |
|
static boolean |
runReport(Object obj,
boolean full,
boolean printall)
A hook to run the tester for any object and produce a test report. |
|
static boolean |
runReports(boolean full,
boolean printall,
Object... objs)
A hook to run the tester for a collection of objects and produce the specified test reports |
|
protected void |
runTests(IExamples f,
boolean full,
boolean printall)
Run the tests, accept the class to be tested as a visitor |
|
boolean |
same(Object obj1,
Object obj2)
Provide a general extensional equality comparison for arbitrary pair of objects |
|
protected boolean |
setTolerance(double epsilon)
Set the relative tolerance for the comparison of inexact numbers |
|
boolean |
success()
Test nothing, just report success. |
|
boolean |
success(String testname)
Test nothing, just report success. |
|
protected void |
testReport()
Report on the number and nature of failed tests |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int errors
protected StringBuilder failedResults
String
that records the results for all failed tests
protected StringBuilder fullTestResults
String
that records all test results
protected int numberOfTests
protected String testname
protected int warnings
Constructor Detail |
---|
public Tester()
Method Detail |
---|
public <T> boolean checkConstructorException(Exception e, String className, Object... args)
Test that verifies that when the constructor for the given class is invoked with the given arguments, it throws the expected exception with the expected message.
e
- An instance of the expected exception -- including the
expected messageclassName
- the name of the class whose constructor is testedargs
- An Ellipsis of arguments for the method
true
if the test succeedspublic <T> boolean checkConstructorException(String testname, Exception e, String className, Object... args)
Test that verifies that when the constructor for the given class is invoked with the given arguments, it throws the expected exception with the expected message.
testname
- The description of this teste
- An instance of the expected exception -- including the
expected messageclassName
- the name of the class whose constructor is testedargs
- An Ellipsis of arguments for the method
true
if the test succeedspublic <T> boolean checkEquivalent(T obj1, T obj2, Equivalence<T> equiv)
Equivalence
function object to determine the equivalence
of the two given objects.
obj1
- the first object to compareobj2
- the second object to compareequiv
- the function object that implements the
Equivalence
comparison
true
if the two objects are equivalentpublic <T> boolean checkEquivalent(T obj1, T obj2, Equivalence<T> equiv, String testname)
Equivalence
function object to determine the equivalence
of the two given objects.
obj1
- the first object to compareobj2
- the second object to compareequiv
- the function object that implements the
Equivalence
comparisontestname
- the String
that describes this test
true
if the two objects are equivalentpublic <T> boolean checkException(Exception e, T object, String method, Object... args)
Test that verifies that when the given object invokes the given method with the given arguments, it throws the expected exception with the expected message.
T
- The type of the object that invokes the given methodobject
- The object that invokes the method to be testedmethod
- The name of the method to teste
- An instance of the expected exception -- including the
expected messageargs
- An Ellipsis of arguments for the method
true
if the test succeedspublic <T> boolean checkException(String testname, Exception e, T object, String method, Object... args)
Test that verifies that when the given object invokes the given method with the given arguments, it throws the expected exception with the expected message.
T
- The type of the object that invokes the given methodtestname
- The description of this teste
- An instance of the expected exception -- including the
expected messageobject
- The object that invokes the method to be testedmethod
- The name of the method to testargs
- An Ellipsis of arguments for the method
true
if the test succeedspublic boolean checkExpect(boolean result)
result
- the test result
true
if the test succeedspublic boolean checkExpect(boolean result, String testname)
testname
- the name of this testresult
- the test result
true
if the test succeedspublic <T> boolean checkExpect(T actual, T expected)
T
- the type of the objects being comparedactual
- the computed value of the type Texpected
- the expected value of the type T
true
if the test succeedspublic <T> boolean checkExpect(T actual, T expected, String testname)
T
- the type of the objects being comparedactual
- the computed value of the type Texpected
- the expected value of the type Ttestname
- the name of this test
true
if the test succeedspublic boolean checkFail(boolean result)
result
- the test result that should fail
true
if the test failspublic boolean checkFail(boolean result, String testname)
result
- the test result that should fail
true
if the test failspublic <T> boolean checkFail(T actual, T expected)
Test that compares two objects of any kind and is expected to fail: comparison failure constitutes a successful test.
Assumes all values that are compared are exact.
T
- the type of the objects being comparedactual
- the computed value of the type Texpected
- the expected value of the type T
true
if the test failspublic <T> boolean checkFail(T actual, T expected, String testname)
Test that compares two objects of any kind and is expected to fail: comparison failure constitutes a successful test.
Assumes all values that are compared are exact.
T
- the type of the objects being comparedactual
- the computed value of the type Texpected
- the expected value of the type Ttestname
- the name of this test
true
if the test failspublic <T> boolean checkInequivalent(T obj1, T obj2, Equivalence<T> equiv)
Equivalence
function object to determine the NON-equivalence
of the two given objects.
obj1
- the first object to compareobj2
- the second object to compareequiv
- the function object that implements the
Equivalence
comparison
true
if the two objects are equivalentpublic <T> boolean checkInequivalent(T obj1, T obj2, Equivalence<T> equiv, String testname)
Equivalence
function object to determine the equivalence
of the two given objects.
obj1
- the first object to compareobj2
- the second object to compareequiv
- the function object that implements the
Equivalence
comparisontestname
- the String
that describes this test
true
if the two objects are equivalentpublic <T> boolean checkInexact(T actual, T expected, double tolerance)
Test that compares two objects of any kind.
The objects can contain inexact values (of the types
double
or float
). These will be compared within
the given relative tolerance. The relative tolerance used in the
comparison will appear on the test report.
T
- the type of the objects being comparedactual
- the computed value of the type Texpected
- the expected value of the type Ttolerance
- the desired relative tolerance
true
if the test succeedspublic <T> boolean checkInexact(T actual, T expected, double tolerance, String testname)
Test that compares two objects of any kind.
The objects can contain inexact values (of the types
double
or float
). These will be compared within
the given relative tolerance. The relative tolerance used in the
comparison will appear on the test report.
T
- the type of the objects being comparedactual
- the computed value of the type Texpected
- the expected value of the type Ttolerance
- the desired relative tolerancetestname
- the name of this test
true
if the test succeedspublic <T> boolean checkInexactFail(T actual, T expected, double tolerance)
Test that compares two objects of any kind and is expected to fail: comparison failure constitutes a successful test.
Allows comparison of inexact values.
T
- the type of the objects being comparedactual
- the computed value of the type Texpected
- the expected value of the type T
true
if the test failspublic <T> boolean checkInexactFail(T actual, T expected, double tolerance, String testname)
Test that compares two objects of any kind and is expected to fail: comparison failure constitutes a successful test.
Allows comparison of inexact values.
T
- the type of the objects being comparedactual
- the computed value of the type Texpected
- the expected value of the type Ttestname
- the name of this test
true
if the test failspublic <T> boolean checkInexactIterable(Iterable<T> actual, Iterable<T> expected, double tolerance)
Test that compares two objects that implement Iterable
interface by traversing over the data.
The objects can contain inexact values (of the types
double
or float
). These will be compared within
the given relative tolerance. The relative tolerance used in the
comparison will appear on the test report.
actual
- the computed value of the type Iterable
expected
- the expected value of the type Iterable
tolerance
- the desired relative tolerance
true
if the test succeedspublic <T> boolean checkInexactIterable(Iterable<T> actual, Iterable<T> expected, double tolerance, String testname)
Test that compares two objects that implement Iterable
interface by traversing over the data.
The objects can contain inexact values (of the types
double
or float
). These will be compared within
the given relative tolerance. The relative tolerance used in the
comparison will appear on the test report.
actual
- the computed value of the type Iterable
expected
- the expected value of the type Iterable
tolerance
- the desired relative tolerancetestname
- the name of this test
true
if the test succeedspublic <T> boolean checkInexactMethod(Object expected, double tolerance, T object, String method, Object... args)
The resulting object can contain inexact values (of the types
double
or float
). These will be compared within
the given relative tolerance. The relative tolerance used in the
comparison will appear on the test report.
T
- The type of the object that invokes the given methodexpected
- The expected result of the method being testedobject
- The object that invokes the method to be testedmethod
- The name of the method to testargs
- An array of arguments for the method - use Array of length 0
if no arguments are needed
true
if the test succeedspublic <T> boolean checkInexactMethod(String testname, Object expected, double tolerance, T object, String method, Object... args)
The resulting object can contain inexact values (of the types
double
or float
). These will be compared within
the given relative tolerance. The relative tolerance used in the
comparison will appear on the test report.
T
- The type of the object that invokes the given methodtestname
- The description of this testexpected
- The expected result of the method being testedobject
- The object that invokes the method to be testedmethod
- The name of the method to testargs
- An array of arguments for the method - use Array of length 0
if no arguments are needed
true
if the test succeedspublic <T> boolean checkInexactNoneOf(double tolerance, T actual, T... expected)
Test that determines whether the value of the given object (of any kind) is not equal to any of the expected results
The expected results can include inexact values.
Providing tolerance < 0
results in an automatic
success of the test.
T
- the type of the objects being comparedactual
- the computed value of the type Texpected
- the expected values of the type T
true
if the test succeedspublic <T> boolean checkInexactNoneOf(String testname, double tolerance, T actual, T... expected)
Test that determines whether the value of the given object (of any kind) is not equal to any of the expected results
The expected results can include inexact values.
Providing tolerance < 0
results in an automatic
success of the test.
T
- the type of the objects being comparedactual
- the computed value of the type Texpected
- the expected values of the type T
true
if the test succeedspublic <T> boolean checkInexactOneOf(double tolerance, T actual, T... expected)
Test that determines whether the value of the given object (of any kind) is the same as one of the expected results
The expected results must be composed of exact values only.
T
- The type of the objects being comparedactual
- The computed value of the type Texpected
- An Ellipsis of the expected values of the type T
true
if the test succeedspublic <T> boolean checkInexactOneOf(String testname, double tolerance, T actual, T... expected)
Test that determines whether the value of the given object (of any kind) is the same as one of the expected results
The expected results must be composed of exact values only.
T
- The type of the objects being comparedtestname
- The name of this testactual
- The computed value of the type Texpected
- An Ellipsis of the expected values of the type T
true
if the test succeedspublic <T> boolean checkInexactTraversal(Traversal<T> actual, Traversal<T> expected, double tolerance)
Test that compares two objects that implement
Traversal
interface by traversing over the data.
The objects can contain inexact values (of the types
double
or float
). These will be compared within
the given relative tolerance. The relative tolerance used in the
comparison will appear on the test report.
actual
- the computed value of the type Traversal
expected
- the expected value of the type Traversal
tolerance
- the desired relative tolerance
true
if the test succeedspublic <T> boolean checkInexactTraversal(Traversal<T> actual, Traversal<T> expected, double tolerance, String testname)
Test that compares two objects that implement
Traversal
interface by traversing over the data.
The objects can contain inexact values (of the types
double
or float
). These will be compared within
the given relative tolerance. The relative tolerance used in the
comparison will appear on the test report.
actual
- the computed value of the type Traversal
expected
- the expected value of the type Traversal
tolerance
- the desired relative tolerancetestname
- the name of this test
true
if the test succeedspublic <T> boolean checkIterable(Iterable<T> actual, Iterable<T> expected)
Iterable
interface by traversing over the data -- objects must be composed of
exact values only
actual
- the computed value of the type Iterable
expected
- the expected value of the type Iterable
true
if the test succeedspublic <T> boolean checkIterable(Iterable<T> actual, Iterable<T> expected, String testname)
Iterable
interface by traversing over the data -- objects must be composed of
exact values only
actual
- the computed value of the type Iterable
expected
- the expected value of the type Iterable
testname
- the name of this test
true
if the test succeedspublic <T> boolean checkMethod(Object expected, T object, String method, Object... args)
Invoke the method with the given name on a given object with the given arguments - check if it produces the expected result
The expected result must be composed of exact values only
T
- The type of the object that invokes the given methodexpected
- The expected result of the method being testedobject
- The object that invokes the method to be testedmethod
- The name of the method to testargs
- An array of arguments for the method - use Array of length 0
if no arguments are needed
true
if the test succeedspublic <T> boolean checkMethod(String testname, Object expected, T object, String method, Object... args)
Invoke the method with the given name on a given object with the given arguments - check if it produces the expected result
The expected result must be composed of exact values only
T
- The type of the object that invokes the given methodtestname
- The description of this testexpected
- The expected result of the method being testedobject
- The object that invokes the method to be testedmethod
- The name of the method to testargs
- An array of arguments for the method - use Array of length 0
if no arguments are needed
true
if the test succeedspublic <T> boolean checkNoneOf(String testname, T actual, T... expected)
Test that determines whether the value of the given object (of any kind) is not equal to any of the expected results
The expected results must be composed of exact values only.
A 'same' item that involved inexact comparison is not considered a match.
T
- the type of the objects being comparedactual
- the computed value of the type Texpected
- the expected values of the type T
true
if the test succeedspublic <T> boolean checkNoneOf(T actual, T... expected)
Test that determines whether the value of the given object (of any kind) is not equal to any of the expected results
The expected results must be composed of exact values only.
A 'same' item that involved inexact comparison is not considered a match.
T
- the type of the objects being comparedactual
- the computed value of the type Texpected
- the expected values of the type T
true
if the test succeedspublic <T> boolean checkNumRange(Number actual, Number low, Number high)
actual
- the computed value of the type Number
low
- the lower limit of the type Number
(inclusive) for this rangehigh
- the upper limit of the type Number
(exclusive) for this range
true
if the test succeedspublic <T> boolean checkNumRange(Number actual, Number low, Number high, boolean lowIncl, boolean highIncl)
actual
- the computed value of the type Number
low
- the lower limit of the type Number
(inclusive) for this rangehigh
- the upper limit of the type Number
(exclusive) for this rangelowIncl
- is the low limit inclusive for this range?highIncl
- is the upper limit inclusive for this range?
true
if the test succeedspublic <T> boolean checkNumRange(Number actual, Number low, Number high, boolean lowIncl, boolean highIncl, String testname)
actual
- the computed value of the type Number
low
- the lower limit of the type Number
(inclusive) for this rangehigh
- the upper limit of the type Number
(exclusive) for this rangelowIncl
- is the low limit inclusive for this range?highIncl
- is the upper limit inclusive for this range?
true
if the test succeedspublic <T> boolean checkNumRange(Number actual, Number low, Number high, String testname)
actual
- the computed value of the type Number
low
- the lower limit of the type Number
(inclusive) for this rangehigh
- the upper limit of the type Number
(exclusive) for this range
true
if the test succeedspublic <T> boolean checkOneOf(String testname, T actual, T... expected)
Test that determines whether the value of the given object (of any kind) is the same as one of the expected results
The expected results must be composed of exact values only.
Warning: If the actual and expected values are String-s, the programmer must provide the test name --- there is no way the tester can determine whether or not the test name has been included.
T
- The type of the objects being comparedtestname
- The name of this testactual
- The computed value of the type Texpected
- An Ellipsis of the expected values of the type T
true
if the test succeedspublic <T> boolean checkOneOf(T actual, T... expected)
Test that determines whether the value of the given object (of any kind) is the same as one of the expected results
The expected results must be composed of exact values only.
Warning: If the actual and expected values are String-s, the programmer must provide the test name --- there is no way the tester can determine whether or not the test name has been included.
T
- The type of the objects being comparedactual
- The computed value of the type Texpected
- An Ellipsis of the expected values of the type T
true
if the test succeedspublic <T> boolean checkRange(Comparable<T> actual, T low, T high)
T
- the type of the objects being comparedactual
- the computed value of the type Tlow
- the lower limit of the type T (inclusive) for this rangehigh
- the upper limit of the type T (exclusive) for this range
true
if the test succeedspublic <T> boolean checkRange(Comparable<T> actual, T low, T high, boolean lowIncl, boolean highIncl)
T
- the type of the objects being comparedactual
- the computed value of the type Tlow
- the lower limit of the type T for this rangehigh
- the upper limit of the type T for this rangelowIncl
- is the low limit inclusive for this range?highIncl
- is the upper limit inclusive for this range?
true
if the test succeedspublic <T> boolean checkRange(Comparable<T> actual, T low, T high, boolean lowIncl, boolean highIncl, String testname)
T
- the type of the objects being comparedactual
- the computed value of the type Tlow
- the lower limit of the type T for this rangehigh
- the upper limit of the type T for this rangelowIncl
- is the low limit inclusive for this range?highIncl
- is the upper limit inclusive for this range?testname
- the name of this test
true
if the test succeedspublic <T> boolean checkRange(Comparable<T> actual, T low, T high, String testname)
T
- the type of the objects being comparedactual
- the computed value of the type Tlow
- the lower limit of the type T (inclusive) for this rangehigh
- the upper limit of the type T (exclusive) for this rangetestname
- the name of this test
true
if the test succeedspublic <T> boolean checkRange(T actual, T low, T high, boolean lowIncl, boolean highIncl, Comparator<T> comp)
T
- the type of the objects being comparedactual
- the computed value of the type Tlow
- the lower limit of the type T (inclusive) for this rangehigh
- the upper limit of the type T (exclusive) for this rangelowIncl
- is the low limit inclusive for this range?highIncl
- is the upper limit inclusive for this range?comp
- The Comparator
used to compare the values
true
if the test succeedspublic <T> boolean checkRange(T actual, T low, T high, boolean lowIncl, boolean highIncl, Comparator<T> comp, String testname)
T
- the type of the objects being comparedactual
- the computed value of the type Tlow
- the lower limit of the type T (inclusive) for this rangehigh
- the upper limit of the type T (exclusive) for this rangelowIncl
- is the low limit inclusive for this range?highIncl
- is the upper limit inclusive for this range?comp
- The Comparator
used to compare the valuestestname
- the name of this test
true
if the test succeedspublic <T> boolean checkRange(T actual, T low, T high, Comparator<T> comp)
T
- the type of the objects being comparedactual
- the computed value of the type Tlow
- the lower limit of the type T (inclusive) for this rangehigh
- the upper limit of the type T (exclusive) for this range
true
if the test succeedspublic <T> boolean checkRange(T actual, T low, T high, Comparator<T> comp, String testname)
T
- the type of the objects being comparedactual
- the computed value of the type Tlow
- the lower limit of the type T (inclusive) for this rangehigh
- the upper limit of the type T (exclusive) for this rangetestname
- the name of this test
true
if the test succeedspublic <T> boolean checkSet(Set<T> actual, Set<T> expected)
Set
interface by comparing data using the equals
method for
comparing the elements of the two sets.
actual
- the computed value of the type Set
expected
- the expected value of the type Set
true
if the test succeedspublic <T> boolean checkSet(Set<T> actual, Set<T> expected, String testname)
Set
interface by comparing data using the equals
method for
comparing the elements of the two sets.
actual
- the computed value of the type Set
expected
- the expected value of the type Set
testname
- the name of this test
true
if the test succeedspublic <T> boolean checkTraversal(Traversal<T> actual, Traversal<T> expected)
Traversal
interface by traversing over the data -- objects must be composed of
exact values only
actual
- the computed value of the type Traversal
expected
- the expected value of the type Traversal
true
if the test succeedspublic <T> boolean checkTraversal(Traversal<T> actual, Traversal<T> expected, String testname)
Traversal
interface by traversing over the data -- objects must be composed of
exact values only
actual
- the computed value of the type Traversal
expected
- the expected value of the type Traversal
testname
- the name of this test
true
if the test succeedsprotected void done(boolean failed)
public boolean fail()
false
public boolean fail(String testname)
testname
- the name of the test
false
protected void fullTestReport()
public static boolean run(Object obj)
obj
- The 'Examples' class instance where the tests are definedprotected void runAnyTests(Object f)
Find all test methods in the class of the given object; run tests and report results.
If the class extends the IExamples
all tests within the
void tests(Tester t)
method are performed.
Otherwise we locate all methods
with names that start with test
and consume one parameter
of the type Tester
and perform the desired tests.
Report only the results of failed tests.
f
- the instance of a class that defines all tests and the data
for themprotected void runAnyTests(Object f, boolean full)
Find all test methods in the class of the given object; run tests and report results.
If the class extends the IExamples
all tests within the
void tests(Tester t)
method are performed.
Otherwise we locate all methods
with names that start with test
and consume one parameter
of the type Tester
and perform the desired tests.
Report test results --- failed or all as specified.
f
- the instance of a class that defines all tests and the data
for themfull
- true
if full test report is desiredprotected void runAnyTests(Object f, boolean full, boolean printall)
Find all test methods in the class of the given object; run tests and report results.
If the class extends the IExamples
all tests within the
void tests(Tester t)
method are performed.
Otherwise we locate all methods
with names that start with test
and consume one parameter
of the type Tester
and perform the desired tests.
Report test results --- failed or all as specified.
Print all data in the class that defines the tests - as specified.
f
- the instance of a class that defines all tests and the data
for themfull
- true if full test report is desiredprintall
- true
if Examples
class data is to be printedpublic static boolean runFullReport(Object... objs)
objs
- An array of 'Examples' class instances where tests are definedpublic static boolean runReport(Object obj, boolean full, boolean printall)
obj
- The 'Examples' class instance where the tests are definedpublic static boolean runReports(boolean full, boolean printall, Object... objs)
full
- true if all test results should be reportedprintall
- true if all data should be displayedobjs
- An array of 'Examples' class instances where tests are definedprotected void runTests(IExamples f, boolean full, boolean printall)
Run the tests, accept the class to be tested as a visitor
An alternative method for running all tests.
f
- the class to be tested -- it defines the method
void tests(Tester t)
that invokes all test
cases.full
- true
if full test report is desiredpublic boolean same(Object obj1, Object obj2)
Provide a general extensional equality comparison for arbitrary pair of objects
Inspector invokes the user-defined same
method, if the
corresponding classes implement the ISame
interface.
obj1
- the first objectobj2
- the second object
true
if the two objects represent the same dataprotected boolean setTolerance(double epsilon)
epsilon
- the desired tolerancepublic boolean success()
true
public boolean success(String testname)
testname
- the name of the test
true
protected void testReport()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |