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, ...)
For example:[code]
// Default tests execution, simple validation and logging of the results.
new MyTestSuite().run();
// Specialized context measuring execution time (default average time, with minimum time in parenthesis).
TimeContext.enter();
try {
new MyTestSuite().run();
} finally {
TimeContext.exit();
}
// Regression tests (no output, AssertionException raised if any test fails).
TestContext.enter(TestContext.REGRESSION); // Or TimeContext.REGRESSION for performance regression test.
try {
new MyTestSuite().run();
} finally {
TestContext.exit();
}
[/code]
Logging/tests contexts do not have to output the results in a text form.
Implementations may store results in databases, spreadsheets or show them graphically.
For example:[code]
// Logs output to console.
LogContext.enter(LogContext.CONSOLE);
try {
new MyTestSuite().run();
} finally {
LogContext.exit();
}[/code]
|