|
J avolution v5.2 (J2SE 1.5+) | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavolution.testing.TestSuite
public abstract class TestSuite
This class represents a collection of test cases
and
detailed information about the test being performed.
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)";
}
};
...
}
Test suites can be run in the current logging context or within
specialized test contexts
:
// 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();
}
Nothing prevent a test suite to run other test suites. It is also
possible to retrieve
all the test cases which
are to be executed by a test suite (for integration with an IDE for
example).
Constructor Summary | |
---|---|
protected |
TestSuite()
Default constructor. |
Method Summary | |
---|---|
java.lang.CharSequence |
getDescription()
Returns the description of this test suite or null if none. |
java.util.List |
getTestCases()
Retrieves the list of test cases to be executed by this test suite. |
abstract void |
run()
Runs this test suite. |
java.lang.String |
toString()
Returns the String representation of this test suite
(the description or the class name by default). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected TestSuite()
Method Detail |
---|
public abstract void run()
run
in interface java.lang.Runnable
public java.util.List getTestCases()
public java.lang.CharSequence getDescription()
null
if none.
null
public java.lang.String toString()
String
representation of this test suite
(the description or the class name by default).
toString
in class java.lang.Object
|
J avolution v5.2 (J2SE 1.5+) | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |