| javolution.context.LogContext javolution.testing.TestContext
All known Subclasses: javolution.testing.TimeContext,
TestContext | abstract public class TestContext extends LogContext (Code) | | This class represents a logging context specialized for testing.
Custom implementations may output results in varied form (e.g. tabular)
and/or perform all kind of measurements (e.g.
TimeContext timing ,
memory usage, etc.) For example:[code]
TestContext tabularLog = new TestContext() { ... } // Outputs to spreadsheet.
TestContext.enter(tabularLog);
try {
TestContext.run(new myTestSuite());
...
} finally {
TestContext.exit();
}[/code]
For automatic regression tests, developers may use the
TestContext.REGRESSION implementation which does not perform any
logging but raises an
AssertionException when an assertion fails.
For example:[code]
TestContext.enter(TestContext.REGRESSION);
try {
TestContext.run(new myTestSuite()); // AssertionError is one assertion fails.
...
} finally {
TestContext.exit();
}[/code]
author: Jean-Marie Dautelle version: 5.2, August 5, 2007 See Also: TestCase |
Field Summary | |
final public static Class | REGRESSION Holds an implementation which does not perform any logging but raises
an
AssertionException when an assertion fails. |
Method Summary | |
public static boolean | assertEquals(String message, Object expected, Object actual) Checks the equality of both objects specified. | public static boolean | assertEquals(Object expected, Object actual) Convenience method equivalent to assertEquals(null, expected, value) . | public static boolean | assertTrue(String message, boolean actual) Convenience method equivalent to assertEquals(message, true, value) .
Parameters: message - the message displayed if assert fails (can be null ) Parameters: actual - the actual value. | public static boolean | assertTrue(boolean actual) Convenience method equivalent to assertEquals(null, true, value) .
Parameters: actual - the actual value. | abstract public boolean | doAssertEquals(String message, Object expected, Object actual) Asserts that two objects are equal.
Parameters: message - the message displayed if assert fails (can be null ) Parameters: expected - the expected result (can be null ). Parameters: actual - the actual result (can be null ). | abstract public void | doTest(TestCase testCase) Executes the specified test case and logs the results. | public static void | test(TestCase testCase) Runs an individual test case (possibly multiple times) and logs the
results. |
REGRESSION | final public static Class REGRESSION(Code) | | Holds an implementation which does not perform any logging but raises
an
AssertionException when an assertion fails.
This implementation can be used for automatic regression tests.
|
assertEquals | public static boolean assertEquals(String message, Object expected, Object actual)(Code) | | Checks the equality of both objects specified. If the current logging
context is a test context then
TestContext.doAssertEquals(StringObjectObject) is called;
otherwise an error message is logged only if the assert fails.
Parameters: message - the message displayed if assert fails (can be null ) Parameters: expected - the expected result (can be null ). Parameters: actual - the actual result (can be null ). true if both expected and actual are equal;false otherwise. |
assertEquals | public static boolean assertEquals(Object expected, Object actual)(Code) | | Convenience method equivalent to assertEquals(null, expected, value) .
Parameters: expected - the expected result (can be null ). Parameters: actual - the actual result (can be null ). |
assertTrue | public static boolean assertTrue(String message, boolean actual)(Code) | | Convenience method equivalent to assertEquals(message, true, value) .
Parameters: message - the message displayed if assert fails (can be null ) Parameters: actual - the actual value. true if actual is true ;false otherwise. |
assertTrue | public static boolean assertTrue(boolean actual)(Code) | | Convenience method equivalent to assertEquals(null, true, value) .
Parameters: actual - the actual value. true if actual is true ;false otherwise. |
doAssertEquals | abstract public boolean doAssertEquals(String message, Object expected, Object actual)(Code) | | Asserts that two objects are equal.
Parameters: message - the message displayed if assert fails (can be null ) Parameters: expected - the expected result (can be null ). Parameters: actual - the actual result (can be null ). true if both expected and actual are equal;false otherwise. |
doTest | abstract public void doTest(TestCase testCase)(Code) | | Executes the specified test case and logs the results.
Parameters: testCase - the test case being executed. |
test | public static void test(TestCase testCase)(Code) | | Runs an individual test case (possibly multiple times) and logs the
results. If the current logging context is a test context then
TestContext.doTest(TestCase) is called; otherwise the name of
test case is logged (info), the test case is excuted once
and the test results are written to the current logging context.
Parameters: testCase - the test case being executed. |
|
|