This class represents a collection of
TestCase test cases and
detailed information about the test being performed. [code]
class TextBuilderSuite extends TestSuite {
public void run() {
TestContext.info("Test Suite for TextBuilder");
TestContext.test(appendInt);
...
}
TestCase appendInt = new TestCase() {
TextBuilder tmp = new TextBuilder();
int i;
public void prepare() {
tmp.reset();
i = MathLib.randomInt(Integer.MIN_VALUE, Integer.MAX_VALUE);
}
public void execute() {
tmp.append(i);
}
public void validate() {
TextContext.assertEquals(String.valueOf(i), tmp.toString());
... // We may also validate min, max, zero boundary cases here.
}
public CharSequence getDescription() {
return "TextBuilder.append(int)";
}
};
...
}[/code]
Test suites can be run in the current logging context or within
specialized
TestContext test contexts :[code]
// Runs test suite directly (validation with results being logged).
new TextBuilderSuite().run();
// Performs regression (no logging but exception if test fails).
TestContext.enter(TestContext.REGRESSION);
try {
new TextBuilderSuite().run();
} finally {
TestContext.exit();
}
// Performance measurements.
TimeContext.enter();
try {
new TextBuilderSuite().run();
} finally {
TimeContext.exit();
}[/code]
Nothing prevent a test suite to run other test suites. It is also
possible
TestSuite.getTestCases() to retrieve all the test cases which
are to be executed by a test suite (for integration with an IDE for
example).
author: Jean-Marie Dautelle version: 5.2, August 19, 2007 See Also:
* Wikipedia: Test Suite |