public abstract class AbstractTestHelper
extends org.junit.Assert
Super class for all test helpers.
In general, subclasses should override mySetUp() and
myTearDown() to create and destroy (using the tearDown()
method) helpers they depend on. All test preparation should be done in the
myPrepareFixture() and all clean up done in myCleanUp().
Clean up should be an idempotent operation (meaning it should be able to run
several times and have the same effect as running a single one). This is
important because test case execution may be aborted and disposal of
resources may not be done. myPrepareFixture() is always called after
clean up so it can assume the test fixture has been previously cleaned.
As a general example, temporary tables should be dropped in the clean up method and created in the prepare fixture. However, the clean up method should be prepared to cope with the error arising from the table not existing. The prepare fixture method, on the other hand, should not catch errors because it is guaranteed that the table has been previously removed.
Note that all helper variables should be static as the
mySetUp() method is called when the first helper (of a specific
class) is created and the myTearDown() is called when the last
helper (of a specific class) is destroyed.
| Constructor and Description |
|---|
AbstractTestHelper()
Creates a new test helper.
|
| Modifier and Type | Method and Description |
|---|---|
double |
getPropDouble(String key)
Gets a test property which has to be defined.
|
int |
getPropInt(String key)
Gets a test property which has to be defined.
|
String |
getPropMString(String key)
Gets a test property which has to be defined.
|
static int |
getTotalHelperCount()
Obtains the total number of helpers created.
|
protected abstract void |
myCleanUp()
Cleans all data that may have been generated by this run or previous run
of the helper.
|
protected abstract void |
myPrepareFixture()
Prepares data for the test.
|
protected abstract void |
mySetUp()
Prepares the helper for execution.
|
protected abstract void |
myTearDown()
Destroys the helper.
|
void |
tearDown()
Destroys a test helper.
|
assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertTrue, assertTrue, fail, failpublic final void tearDown()
throws Exception
Exception - failedpublic final String getPropMString(String key)
key - the property key (the package name will be automatically
prepended)public final int getPropInt(String key)
key - the property key (the package name will be automatically
prepended)public final double getPropDouble(String key)
key - the property key (the package name will be automatically
prepended)public static int getTotalHelperCount()
protected abstract void mySetUp()
throws Exception
Exception - failedprotected abstract void myTearDown()
throws Exception
Exception - failedprotected abstract void myCleanUp()
throws Exception
Exception - failedCopyright © 2015. All rights reserved.