All Packages Class Hierarchy This Package Previous Next Index
Class ccl.util.Test
java.lang.Object
|
+----ccl.util.Test
- public abstract class Test
- extends Object
- implements Runnable
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
- Version:
- 1999-09-03 $Id: Test.java 1.16 2000/05/14 14:30:37 clemens Exp clemens $
- Author:
-
Chr. Clemens Lee
<
clemens@kclee.com
>
- See Also:
- UtilTest
-
_bLastSubtest
-
-
_bLastSuccessfull
-
-
_bRedirectStandardStreams
-
-
_bShowLiveSignals
-
-
_bTest
-
-
_bTiming
-
-
_lBugs
-
-
_lGLobalTests
-
-
_lLastBugs
-
-
_lLastLocalTests
-
-
_lLocalTests
-
-
_newErr
-
-
_newOut
-
-
_oldErr
-
-
_oldOut
-
-
_oValue
-
-
_sLastSubTest
-
-
_subtests
-
-
_vCalendars
-
-
Test()
-
-
Test(Test)
-
-
_check(boolean)
-
-
_doIt()
- Inherit this method to do your test inside of it.
-
_ensureRedirectedStreams()
- If standard streams are redirected, ensure that
redirected streams are in place.
-
_ensureStandardStreams()
- If standard streams are redirected, normal streams
are used now.
-
_enterSubTest(String)
-
-
_exitSubTest()
-
-
_getValue()
-
-
_increment()
-
-
_printMessage(String)
-
-
_printStackTrace()
-
-
_processFailure()
-
-
_setOutNew()
- When we need to switch between two std output streams,
this method helps doing so.
-
_setOutOld()
- When we need to switch between two std output streams,
this method helps doing so.
-
_setTests(Test)
-
Deprecated.
-
_showLiveSignal()
-
-
_showLiveSignals(boolean)
-
Deprecated.
-
bugIf(boolean)
-
-
bugIf(boolean, String)
-
-
bugIf(boolean, String, Throwable)
-
-
getBugs()
-
-
getComment()
- Return a one line comment for this test.
-
getGlobalTests()
-
-
getLocalTests()
-
-
getTestDirectory()
-
-
getValue()
-
-
initialize(String[])
- Process the arguments from the main class here.
-
isTest()
-
-
isTiming()
-
-
isVerbose()
-
-
main(String[])
- example code for a real test main method
Test pTest = (Test)(new SomeTest());
pTest.initialize( argv );
pTest.setVerbose( true );
pTest.run();
printResult( pTest );
System.exit( 0 );
-
printResult(Test)
-
-
redirectStandardStreams(boolean)
- Redirect stdout and stderr into private streams
so the do not confuse the user with test output.
-
run()
-
-
setBug()
-
-
setTests(Test)
-
-
setTiming(boolean)
- You want timing information? Set this to true!
-
setValue(Object)
-
-
setVerbose(boolean)
-
-
toString()
-
_lGLobalTests
private long _lGLobalTests
_lLocalTests
private long _lLocalTests
_lBugs
private long _lBugs
_bTiming
private boolean _bTiming
_bShowLiveSignals
private boolean _bShowLiveSignals
_bLastSuccessfull
private boolean _bLastSuccessfull
_bLastSubtest
private boolean _bLastSubtest
_subtests
private int _subtests
_lLastBugs
private long _lLastBugs
_lLastLocalTests
private long _lLastLocalTests
_sLastSubTest
private String _sLastSubTest
_vCalendars
private Vector _vCalendars
_oValue
private static Object _oValue
_bTest
private static boolean _bTest
_bRedirectStandardStreams
private static boolean _bRedirectStandardStreams
_oldOut
private static PrintStream _oldOut
_newOut
private static PrintStream _newOut
_oldErr
private static PrintStream _oldErr
_newErr
private static PrintStream _newErr
Test
public Test()
Test
public Test(Test tstParent_)
_showLiveSignal
private void _showLiveSignal()
_getValue
protected Object _getValue()
_enterSubTest
protected void _enterSubTest(String sName_)
- Parameters:
- sName_ - e.g. "jacob".
_exitSubTest
protected void _exitSubTest()
_setTests
protected void _setTests(Test pTest_)
- Note: _setTests() is deprecated.
Use setTests(..) instead.
_increment
protected void _increment()
_showLiveSignals
protected void _showLiveSignals(boolean bShowLiveSignals_)
- Note: _showLiveSignals() is deprecated.
Use setVerbose(..) instead.
getLocalTests
public long getLocalTests()
getGlobalTests
public long getGlobalTests()
getBugs
public long getBugs()
setBug
public void setBug()
setValue
public void setValue(Object oValue_)
isVerbose
public boolean isVerbose()
setVerbose
public void setVerbose(boolean bVerbose_)
setTiming
public void setTiming(boolean bTiming_)
- You want timing information? Set this to true!
isTiming
public boolean isTiming()
printResult
public static void printResult(Test pTest_)
_processFailure
private void _processFailure()
_check
private boolean _check(boolean bCondition_)
_printStackTrace
private void _printStackTrace()
_printMessage
private void _printMessage(String sDescription)
bugIf
public boolean bugIf(boolean bCondition)
bugIf
public boolean bugIf(boolean bCondition,
String sDescription)
bugIf
public boolean bugIf(boolean bCondition,
String sDescription,
Throwable pThrowable)
_doIt
protected abstract void _doIt() throws Exception
- Inherit this method to do your test inside of it.
- Throws: Exception
- Whatever can go wrong.
run
public void run()
main
public static void main(String argv[])
- example code for a real test main method
Test pTest = (Test)(new SomeTest());
pTest.initialize( argv );
pTest.setVerbose( true );
pTest.run();
printResult( pTest );
System.exit( 0 );
initialize
public void initialize(String asArg_[])
- Process the arguments from the main class here.
This way you can pass arguments to this test also
from the test center, which does not use the
main method to invoke a test.
isTest
public static boolean isTest()
getValue
public static Object getValue()
getTestDirectory
public String getTestDirectory()
toString
public String toString()
- Overrides:
- toString in class Object
setTests
public void setTests(Test test_)
getComment
public String getComment()
- Return a one line comment for this test.
Should be overwritten be test classes inheriting
from this class.
_setOutNew
private static void _setOutNew()
- When we need to switch between two std output streams,
this method helps doing so. E.g. we redirect
std out but want to print a "test SUCCESS" message,
then we use _setOutOld, print, _setOutNew methods.
_setOutOld
private static void _setOutOld()
- When we need to switch between two std output streams,
this method helps doing so. E.g. we redirect
std out but want to print a "test SUCCESS" message,
then we use _setOutOld, print, _setOutNew methods.
_ensureStandardStreams
private static void _ensureStandardStreams()
- If standard streams are redirected, normal streams
are used now.
_ensureRedirectedStreams
private static void _ensureRedirectedStreams()
- If standard streams are redirected, ensure that
redirected streams are in place.
redirectStandardStreams
public static void redirectStandardStreams(boolean bRedirect_)
- Redirect stdout and stderr into private streams
so the do not confuse the user with test output.
Look at the class documentation at the top for
detailed stdout redirection documentation.
All Packages Class Hierarchy This Package Previous Next Index