|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ccl.util.Test
Framework and base class for all tests. Inherit _doit in your test and use bugIf( boolean ) statements for your actual test comparisons.
Features:
- support for stdout and stderr redirecting
Stdout redirection
Sometimes you test code which prints something to the console while for the test you don't want to confuse the user, since the test wants to print status information as well.
Console output will be redirected into two byte streams when desired (use 'Test.redirectStandardStreams( true )'). The test output will still be printed to the normal standard output streams.
When redirection takes place, the test can get a string with the last output to these streams and use this information for testing purposes as well. This buffer can also be cleaned anytime on purpose.
For an example how to write your own tests take a look at the ccl.util.test.UtilTest class
UtilTest
Constructor Summary | |
Test()
|
|
Test(Test tstParent_)
|
Method Summary | |
protected abstract void |
_doIt()
Inherit this method to do your test inside of it. |
protected void |
_enterSubTest(java.lang.String sName_)
|
protected void |
_exitSubTest()
|
protected java.lang.Object |
_getValue()
|
protected void |
_increment()
|
protected void |
_setTests(Test pTest_)
Deprecated. Use setTests(..) instead. |
protected void |
_showLiveSignals(boolean bShowLiveSignals_)
Deprecated. Use setVerbose(..) instead. |
void |
assert(boolean bCheck_)
Conduct a check that a given object fullfills a given condition. |
void |
assert(boolean bCheck_,
java.lang.String sMessage_)
Conduct a check that a given object fullfills a given condition. |
void |
assertNotNull(java.lang.Object object_)
Conduct a check that a given object is not null. |
void |
assertNotNull(java.lang.Object object_,
java.lang.String sMessage_)
Conduct a check that a given object is not null. |
boolean |
bugIf(boolean bCondition)
|
boolean |
bugIf(boolean bCondition,
java.lang.String sDescription)
|
boolean |
bugIf(boolean bCondition,
java.lang.String sDescription,
java.lang.Throwable pThrowable)
|
long |
getBugs()
|
java.lang.String |
getComment()
Return a one line comment for this test. |
long |
getGlobalTests()
|
long |
getLocalTests()
|
java.lang.String |
getTestClassDirectory()
Deprecated. Use getTestDirectory instead as this method will not work well together with jar files. |
java.lang.String |
getTestDirectory()
This method returns the full path of a dedicated test directory under the application directory. |
static java.lang.Object |
getValue()
|
void |
initialize(java.lang.String[] asArg_)
Process the arguments from the main class here. |
static boolean |
isTest()
|
boolean |
isTiming()
|
boolean |
isVerbose()
|
static void |
main(java.lang.String[] argv)
example code for a real test main method |
static void |
printResult(Test pTest_)
|
static void |
redirectStandardStreams(boolean bRedirect_)
Redirect stdout and stderr into private streams so the do not confuse the user with test output. |
void |
run()
|
void |
setBug()
|
void |
setTests(Test test_)
|
void |
setTiming(boolean bTiming_)
You want timing information? Set this to true! |
void |
setValue(java.lang.Object oValue_)
|
void |
setVerbose(boolean bVerbose_)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Test()
public Test(Test tstParent_)
Method Detail |
protected java.lang.Object _getValue()
protected void _enterSubTest(java.lang.String sName_)
sName_
- e.g. "jacob".protected void _exitSubTest()
protected void _setTests(Test pTest_)
protected void _increment()
protected void _showLiveSignals(boolean bShowLiveSignals_)
public long getLocalTests()
public long getGlobalTests()
public long getBugs()
public void setBug()
public void setValue(java.lang.Object oValue_)
public boolean isVerbose()
public void setVerbose(boolean bVerbose_)
public void setTiming(boolean bTiming_)
public boolean isTiming()
public static void printResult(Test pTest_)
public boolean bugIf(boolean bCondition)
public boolean bugIf(boolean bCondition, java.lang.String sDescription)
public boolean bugIf(boolean bCondition, java.lang.String sDescription, java.lang.Throwable pThrowable)
public void assertNotNull(java.lang.Object object_)
public void assertNotNull(java.lang.Object object_, java.lang.String sMessage_)
sMessage_
- The message gets printed when the
assertion fails.public void assert(boolean bCheck_)
public void assert(boolean bCheck_, java.lang.String sMessage_)
sMessage_
- The message gets printed when the
assertion fails.protected abstract void _doIt() throws java.lang.Exception
java.lang.Exception
- Whatever can go wrong.public void run()
run
in interface java.lang.Runnable
public static void main(java.lang.String[] argv)
Test pTest = (Test)(new SomeTest()); pTest.initialize( argv ); pTest.setVerbose( true ); pTest.run(); printResult( pTest ); System.exit( 0 );
public void initialize(java.lang.String[] asArg_)
public static boolean isTest()
public static java.lang.Object getValue()
public java.lang.String getTestClassDirectory()
getTestDirectory()
public java.lang.String getTestDirectory()
public java.lang.String toString()
toString
in class java.lang.Object
public void setTests(Test test_)
public java.lang.String getComment()
public static void redirectStandardStreams(boolean bRedirect_)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |