| Tester: An Introduction | |||||||||||||||||
The library assumes that all methods that invoke tests are defined within one class, typically named
Note: For an explanation of the design of tests that involve inexact numbers, please refer to the document Comparing Inexact Values. The following class:
import tester.*;
class SimpleExamples{
String hello = "hello";
String world = "world";
void testStrings(Tester t){
t.checkExpect(5, new Integer(5));
t.checkExpect(hello.equals(world), false);
t.checkExpect(hello.length(), world.length(), "OK");
t.checkExpect(hello, world, "will fail");
}
}
produces the following results:
SimpleExamples:
---------------
new SimpleExamples:1(
this.hello = "hello"
this.world = "world")
---------------
Found 1 test methods
Ran 4 tests.
1 test failed.
Test results:
Success in the test number 1
actual: expected:
5 5
Success in the test number 2
actual: expected:
false false
Success in the test number 3
OK
actual: expected:
5 5
Error in test number 4
will fail
tester.ErrorReport: Error trace:
at SimpleExamples.testStrings(SimpleExamples.java:11)
actual: expected:
"hello"................................ "world"
Failed 1 out of 4 tests.
DONE
| ||||||||||||||||||
| last updated on Fri Apr 1 14:26:43 EDT 2011 | generated with DrRacket |