|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjunit.framework.Assert
junit.extensions.TestDecorator
junit.extensions.TestSetup
org.opensubsystems.core.persist.db.DatabaseTestSetup
public class DatabaseTestSetup
This class makes sure that the database is propertly initialized before the tests are executed and that the database is properly shutdown when all tests are finished. ALL TESTCASES DERIVED FROM DatabaseTest CLASS AND ALL TEST SUITES INCLUDING SUCH TEST CASES SHOULD FOLLOW THE DIRECTION BELLOW. To use this setup in your class define your tests as class MyTest { public static Test suite( ) { TestSuite suite = new DatabaseTestSuite("MyTest"); suite.addTestSuite(MyTestInternal.class); TestSetup wrapper = new DatabaseTestSetup(suite); return wrapper; } public static class MyTestInternal extends TestCase { // add tests here } } This way if the top level test gets executed, it will be executed as a suite and this setup will be invoked for all tests in the suite and therefore database will be properly initialized and shutdown. If you want to include these tests in another suite, DO NOT ADD MyTest but instead add MyTest.MyTestInternal. This way the suite which includes this test can invoke the setup once for all included tests. To create a suite of suites, define your suite as public final class MyTests { public static Test suite( ) { TestSuite suite = new DatabaseTestSuite("My tests"); addGenericTests(suite); TestSetup wrapper = new DatabaseTestSetup(suite); return wrapper; } public static void addGenericTests( TestSuite suite ) { // Here we are adding single test case class using the inner internal class suite.addTestSuite(MyTestInternal.class); // Here we are including tests from another suite without including the // DatabaseTestSetup again MyOtherTests.addGenericTests(suite); } }
| Field Summary | |
|---|---|
protected static java.lang.String |
DEFAULT_PROPERTY_FILE
Default property file used to run tests. |
| Fields inherited from class junit.extensions.TestDecorator |
|---|
fTest |
| Constructor Summary | |
|---|---|
DatabaseTestSetup(junit.framework.Test test)
Create new DatabaseTestSetup. |
|
| Method Summary | |
|---|---|
protected void |
setUp()
Set up environment for the test cases. |
protected void |
tearDown()
Restore original environment after all the tests were run. |
| Methods inherited from class junit.extensions.TestSetup |
|---|
run |
| Methods inherited from class junit.extensions.TestDecorator |
|---|
basicRun, countTestCases, getTest, toString |
| Methods inherited from class junit.framework.Assert |
|---|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final java.lang.String DEFAULT_PROPERTY_FILE
| Constructor Detail |
|---|
public DatabaseTestSetup(junit.framework.Test test)
test - - test to run| Method Detail |
|---|
protected void setUp()
throws java.lang.Exception
setUp in class junit.extensions.TestSetupjava.lang.Exception - - an error has occured while setting up tests
protected void tearDown()
throws java.lang.Exception
tearDown in class junit.extensions.TestSetupjava.lang.Exception - - an error has occured while tearing down tests
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||