Provides classes and interfaces to facilitate all aspects of testing including unit tests, performance, regression, etc.
Too often unit tests focus on one aspect: "Validation". But although a code modification might not break your application; it may very well impact the performance significantly (for the better or the worst). External elements (JVM, O/S, memory available, runtime options) are also likely to affect performance. It is therefore important to not only be able to measure the performance but also to detect automatically (regression tests) when any change you make in your code or runtime environment breaks your timing assumptions.
This test framework addresses not only the validation aspect of testing but performance and regression as well.
In a normal situation, the developer creates a
{@link javolution.testing.TestSuite TestSuite} which is basically
a collection of {@link javolution.testing.TestCase TestCase} logically grouped
together.
(Note: You will find examples of test suites in the javolution.*
source directory).
Then by running within an appropriate {@link javolution.testing.TestContext TestContext}, the developer
can focus on any particular aspect of interest (behavior, performance, memory usage, ...)
[code]
// Default context (validation).
TextContext.enter();
try {
TestContext.run(myTestSuite);
TestContext.run(myTestSuite.tests().get(3)); // Runs individual test case.
...
} finally {
TestContext.exit(); // Prints test result statistics.
}
// Time context (measures execution time)
TimeContext.enter();
try {
TestContext.run(myTestSuite);
...
} finally {
TimeContext.exit();
}
// Regression tests (no output, AssertionException raised if any test fails).
TestContext.enter(TestContext.REGRESSION); // Or TimeContext.REGRESSION for performance based regression.
try {
TestContext.run(myTestSuite);
...
} finally {
TestContext.exit();
}
[/code]
Logging/tests contexts do not have to output test results in a text form.
Implementations may store results in databases, spreadsheets or show them graphically (IDE plugin).
[code]
// Logs output to console.
TestContext.enter(TestContext.CONSOLE);
try {
TestContext.run(myTestSuite);
...
} finally {
TestContext.exit();
}[/code]