J avolution v5.4 (J2SE 1.6+)

Package javolution.testing

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

See:
          Description

Class Summary
JUnitContext This class represents a test context forwarding events to the JUnit framework (e.g.
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 grouping of potentially parallelizabletest cases.
      class TypeFormatTestSuite extends TestSuite {
           public TypeFormatTestSuite() {
                addTest(new ParseBoolean());
                addTest(new ParseInt().ignore(true)); // Adds this test case but it is ignored for now.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD WIDTH="15%"><B><A HREF="../../javolution/testing/TimeContext.html" title="class in javolution.testing">TimeContext</A></B></TD>
<TD> This class represents a <A HREF="../../javolution/testing/TestContext.html" title="class in javolution.testing"><CODE>test context</CODE></A> specialized
     for measuring execution time.</TD>
</TR>
</TABLE>
&nbsp;

<P>

<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Exception Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD WIDTH="15%"><B><A HREF="../../javolution/testing/AssertionException.html" title="class in javolution.testing">AssertionException</A></B></TD>
<TD>This class represents an exception which might be raised when 
 a testing assertion fails (see <A HREF="../../javolution/testing/TestContext.html#REGRESSION"><CODE>TestContext.REGRESSION</CODE></A>).</TD>
</TR>
</TABLE>
&nbsp;

<P>
<A NAME="package_description"><!-- --></A><H2>
Package javolution.testing Description
</H2>

<P>
<p> Provides classes and interfaces to facilitate all aspects of testing including 
    unit tests, performance, regression, etc.</p>
    
<p> 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.</p>
    
<p> This test framework addresses not only the validation aspect of testing but 
    performance and regression as well.</p>
    
<p> In a normal situation, the developer creates a 
    <A HREF="../../javolution/testing/TestSuite.html" title="class in javolution.testing"><CODE>TestSuite</CODE></A> which is basically
    a collection of <A HREF="../../javolution/testing/TestCase.html" title="class in javolution.testing"><CODE>TestCase</CODE></A> logically grouped 
    together.
    <i>(Note: You will find examples of test suites in the <code>javolution.*</code> source directory)</i>.
    Then by running within an appropriate <A HREF="../../javolution/testing/TestContext.html" title="class in javolution.testing"><CODE>TestContext</CODE></A>, 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();
    }
    
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).
    // Logs output to console.
    TestContext.enter(TestContext.CONSOLE);
    try {
        TestContext.run(myTestSuite);
        ...
    } finally {
        TestContext.exit();
    }


J avolution v5.4 (J2SE 1.6+)

Copyright © 2005 - 2009 Javolution.