|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectContext
LogContext
TestContext
JUnitContext
public class JUnitContext
This class represents a test context forwarding events to the
JUnit framework (e.g. asserts). Its purpose is to facilitate
test integration with JUnit. For example:
public class JavolutionTest extends junit.framework.TestSuite {
public static junit.framework.Test suite() {
JavolutionTest suite = new JavolutionTest();
for (TestCase test : new TypeFormatTestSuite().tests()) {
suite.addTest(new JUnitTestCase(test));
}
... // Adds more test cases from Javolution test suites.
return suite;
}
public static class JUnitTestCase extends junit.framework.TestCase {
private final TestCase _test;
public JUnitTestCase(TestCase test) {
_test = test;
}
public String getName() {
return _test.getName();
}
protected void runTest() throws Exception {
JUnitContext.enter();
try {
JUnitContext.run(_test);
} finally {
JUnitContext.exit();
}
}
}
}
Field Summary |
---|
Fields inherited from class TestContext |
---|
CONSOLE, DEFAULT, REGRESSION |
Fields inherited from class LogContext |
---|
NULL, STANDARD, SYSTEM_OUT |
Fields inherited from class Context |
---|
ROOT |
Constructor Summary | |
---|---|
JUnitContext()
|
Method Summary | |
---|---|
protected boolean |
doAssert(boolean value,
CharSequence message)
Asserts the specified value is true . |
protected void |
doRun(TestCase testCase)
Executes the specified test case and logs the results. |
protected void |
doRun(TestSuite testSuite)
Executes the specified test suite and logs the results. |
static void |
enter()
Enters a JUnit test context. |
static void |
exit()
Exits the current JUnit test context. |
protected void |
logMessage(String category,
CharSequence message)
Logs the message of specified category (examples of category are "debug", "info", "warning", "error"). |
Methods inherited from class LogContext |
---|
debug, debug, debug, enterAction, error, error, error, error, error, error, error, exitAction, getCurrentLogContext, getDefault, info, info, info, isDebugLogged, isErrorLogged, isInfoLogged, isLogged, isWarningLogged, logDebug, logError, logInfo, logWarning, warning, warning, warning |
Methods inherited from class Context |
---|
enter, enter, exit, exit, getCurrentContext, getOuter, getOwner, setConcurrentContext, toString |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JUnitContext()
Method Detail |
---|
public static void enter()
junit.framework.AssertionFailedError
if an assert
fails.
public static void exit()
ClassCastException
- if the current context is not a JUnit context.protected void doRun(TestSuite testSuite) throws Exception
TestContext
doRun
in class TestContext
testSuite
- the test suite to be executed.
Exception
TestContext.doRun(javolution.testing.TestCase)
protected void doRun(TestCase testCase) throws Exception
TestContext
ignored
,
the default implementation runs setUp
,
execute
, validate
and tearDown
in sequence.
doRun
in class TestContext
testCase
- the test case being executed if not marked ignored.
Exception
protected boolean doAssert(boolean value, CharSequence message)
TestContext
true
.
The default implementation logs an error message including the code
location of the assert if the assert checks fails. For example:
[error] NaN expected but found Infinity
at javolution.TextTestSuite$DoubleParseDouble.validate(TextTestSuite.java:389)
doAssert
in class TestContext
value
- the boolean value to be tested.message
- the message to be displayed if assert fails (can be null
).
protected void logMessage(String category, CharSequence message)
LogContext
logMessage
in class LogContext
category
- an identifier of the category of the messages logged.message
- the message itself.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |