Overview | Package | Class | Tree | Deprecated | Index | Help
| J avolution v5.3 (J2SE 1.5+)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javolution.testing
Class JUnitContext

    java.lang.Object
      javolution.context.Context
          javolution.context.LogContext
              javolution.testing.TestContext
                  javolution.testing.JUnitContext

All Implemented Interfaces:
  java.io.Serializable, XMLSerializable

    public class JUnitContext

extends TestContext

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:``

         class JUnitTest extends junit.framework.TestCase {
            public void testTypeFormat() throws Exception {
                JUnitContext.enter();
                try {
                    JUnitContext.run(new TypeFormatTest()); // Raises JUnit AssertionFailedError if test fails.
                } finally {
                    JUnitContext.exit();
                }
           }
        }

Version:
  5.3, March 21, 2009
Author:
  Jean-Marie Dautelle
See Also:
  Serialized Form

Field Summary

Fields inherited from class javolution.testing.TestContext
`CONSOLE, DEFAULT, REGRESSION`

Fields inherited from class javolution.context.LogContext
`NULL, STANDARD, SYSTEM_OUT`

Fields inherited from class javolution.context.Context
`ROOT`

Constructor Summary
`JUnitContext()`

Method Summary
`protected boolean` | `doAssert(boolean value, java.lang.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(java.lang.String category, java.lang.CharSequence message)` Logs the message of specified category (examples of category are "debug", "info", "warning", "error").

Methods inherited from class javolution.testing.TestContext
`assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertException, assertException, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, run, run`

Methods inherited from class javolution.context.LogContext
`debug, debug, debug, debug, debug, debug, enterAction, error, error, error, error, error, exitAction, getCurrent, getDefault, info, info, info, info, info, info, isDebugLogged, isErrorLogged, isInfoLogged, isLogged, isWarningLogged, logDebug, logError, logInfo, logWarning, warning, warning, warning, warning, warning, warning`

Methods inherited from class javolution.context.Context
`enter, enter, exit, exit, getOuter, getOwner, setCurrent, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### JUnitContext

    public JUnitContext()

Method Detail

### enter

    public static void enter()

  Enters a JUnit test context. This context raises a `junit.framework.AssertionFailedError` if an assert fails.

### exit

    public static void exit()

  Exits the current JUnit test context.

  Throws:
    `java.lang.ClassCastException` - if the current context is not a JUnit context.

### doRun

    protected void doRun(TestSuite testSuite)
                  throws java.lang.Exception

  Description copied from class: `TestContext`
  Executes the specified test suite and logs the results. The default implementation runs all the test cases.

  Overrides:
    `doRun` in class `TestContext`
  Parameters:
    `testSuite` - the test suite to be executed.
  Throws:
    `java.lang.Exception`
  See Also:
    `TestContext.doRun(javolution.testing.TestCase)`

### doRun

    protected void doRun(TestCase testCase)
                  throws java.lang.Exception

  Description copied from class: `TestContext`
  Executes the specified test case and logs the results. If the test case is not marked `ignored`, the default implementation runs `setUp`, `execute`, `validate` and `tearDown` in sequence.

  Overrides:
    `doRun` in class `TestContext`
  Parameters:
    `testCase` - the test case being executed if not marked ignored.
  Throws:
    `java.lang.Exception`

### doAssert

    protected boolean doAssert(boolean value,
                               java.lang.CharSequence message)

  Description copied from class: `TestContext`
  Asserts the specified value is `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)

  `

  Overrides:
    `doAssert` in class `TestContext`
  Parameters:
    `value` - the boolean value to be tested.
    `message` - the message to be displayed if assert fails (can be `null`).
  Returns:
    the specified value.

### logMessage

    protected void logMessage(java.lang.String category,
                              java.lang.CharSequence message)

  Description copied from class: `LogContext`
  Logs the message of specified category (examples of category are "debug", "info", "warning", "error").

  Specified by:
    `logMessage` in class `LogContext`
  Parameters:
    `category` - an identifier of the category of the messages logged.
    `message` - the message itself.

Overview | Package | Class | Tree | Deprecated | Index | Help
| J avolution v5.3 (J2SE 1.5+)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2005 - 2009 Javolution.