[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

New Unit Test framework for Ozone...



Hi,

  I just commit a new test framework for Ozone based on JUnit 3.6. The
document is available under org/ozoneDB/test/package.html. The attached
is a description of the usage of the Unit Test from the package.html.

  Any idea on establishing guideline writting Unit Test for Ozone? The
guile line we use internally in DigitalSesame is as following:

1. For each concerete class com/d11e/Foo.java, a UnitTest named
com/d11e/FooTestCase.java is created. 

2. For each package, a AllTestSuite.java is created to include all Unit
Test in the package.

3. Unit test should be as comprehensive as possible and should cover
methods that are more than get/set.

4. All TestSuite must be passed before codes are committed into the CVS.

David LI
DigitalSesame

----
Package org.ozoneDB.test Description 

This package provide the JUnit test framework for Ozone. This version is
compatible with JUnit 3.6. 

Important Classes

OzoneTestCase

OzoneTestCase is the base for all Ozone TestCase. It includes access to
the database setup by the TestRunner. 

The following is an example for to write a OzoneTestCase. 

packge com.foo;

import junit.framework.*;
import org.ozoneDB.test.OzoneTestCase;
import org.ozoneDB.test.simple.*;

package FooTestCase extends OzoneTestCase {

  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(FooTestCase.class);
    return suite;
  }

  public void testCreate() {
    // db() provide the access to database setup by TestRunner
    Auto auto = (Auto)db().createObject(AutoImpl.class.getName()); 
    assertNotNull(auto);
    // Test away!!!
  }
}

OzoneTestRunner

Once you have the TestCase written, you will want to run the Test.
OzoneTestRunner provides the environment to run Unit Test for Ozone.

Usage: ojvm org.ozoneDB.test.OzoneTestRunner {-local | -remote
[-host=HOST] [-port=PORT]} [-debug]

     -local: use local database 
     -remote: use remote database 
         -host=HOST: the database server host 
         -port=PORT: the database server port 
     -debug: enable the debugging output 

Note: The OzoneTestRunner's logging is control by Log4J. You can use the
log4j in your TestCase. 

Reference:

     Log4J: http://jakarta.apache.org/log4j/docs/index.html 
     JUnit: http://www.junit.org