J avolution v5.2 (J2SE 1.5+)

Package javolution.testing

Provides classes and interfaces to facilitate all aspects of testing including unit tests, performance, regression, etc.

See:
          Description

Class Summary
TestCase This class represents a test case which can be used for validation, performance and regression tests.
TestContext This class represents a logging context specialized for testing.
TestSuite This class represents a collection of test cases and detailed information about the test being performed.
TimeContext This class represents a test context specialized for measuring execution time.
 

Exception Summary
AssertionException This class represents an exception which might be raised when a testing assertion fails (see TestContext.REGRESSION).
 

Package javolution.testing Description

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 TestSuite which is basically a collection of TestCase logically grouped together. (Note: You will find examples of test suites in the javolution.* source directory). Then by running within an appropriate TestContext, the developer can focus on any particular aspect of interest (behavior, performance, memory usage, ...) For example:

    
    // 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();
    }
    
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:
    // Logs output to console.
    LogContext.enter(LogContext.CONSOLE);
    try {
         new MyTestSuite().run();
    } finally {
        LogContext.exit();
    }


J avolution v5.2 (J2SE 1.5+)

Copyright © 2005 - 2007 Javolution.