The Spring Framework

org.springframework.test.context.junit4
Class SpringJUnit4ClassRunner

java.lang.Object
  extended by org.junit.runner.Runner
      extended by org.junit.internal.runners.JUnit4ClassRunner
          extended by org.springframework.test.context.junit4.SpringJUnit4ClassRunner
All Implemented Interfaces:
Filterable, Sortable

public class SpringJUnit4ClassRunner
extends org.junit.internal.runners.JUnit4ClassRunner

SpringJUnit4ClassRunner is a custom extension of JUnit4ClassRunner which provides functionality of the Spring TestContext Framework to standard JUnit 4.4+ tests by means of the TestContextManager and associated support classes and annotations.

The following list constitutes all annotations currently supported directly by SpringJUnit4ClassRunner. (Note that additional annotations may be supported by various TestExecutionListeners)

Since:
2.5
Author:
Sam Brannen
See Also:
TestContextManager

Constructor Summary
SpringJUnit4ClassRunner(Class<?> clazz)
          Constructs a new SpringJUnit4ClassRunner and initializes a TestContextManager to provide Spring testing functionality to standard JUnit tests.
 
Method Summary
protected  Object createTest()
          Delegates to JUnit4ClassRunner.createTest() to create the test instance and then to a TestContextManager to prepare the test instance for Spring testing functionality.
protected  TestContextManager createTestContextManager(Class<?> clazz)
          Creates a new TestContextManager.
protected  TestContextManager getTestContextManager()
          Gets the TestContextManager associated with this runner.
protected  void invokeTestMethod(Method method, RunNotifier notifier)
          Invokes the supplied test method and notifies the supplied RunNotifier of the appropriate events.
 
Methods inherited from class org.junit.internal.runners.JUnit4ClassRunner
classAnnotations, filter, getDescription, getName, getTestClass, getTestMethods, methodDescription, run, runMethods, sort, testAnnotations, testName, validate, wrapMethod
 
Methods inherited from class org.junit.runner.Runner
testCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpringJUnit4ClassRunner

public SpringJUnit4ClassRunner(Class<?> clazz)
                        throws org.junit.internal.runners.InitializationError
Constructs a new SpringJUnit4ClassRunner and initializes a TestContextManager to provide Spring testing functionality to standard JUnit tests.

Parameters:
clazz - the Class object corresponding to the test class to be run.
Throws:
org.junit.internal.runners.InitializationError
See Also:
createTestContextManager(Class)
Method Detail

createTest

protected Object createTest()
                     throws Exception
Delegates to JUnit4ClassRunner.createTest() to create the test instance and then to a TestContextManager to prepare the test instance for Spring testing functionality.

Overrides:
createTest in class org.junit.internal.runners.JUnit4ClassRunner
Returns:
a new test instance
Throws:
Exception
See Also:
JUnit4ClassRunner.createTest(), TestContextManager.prepareTestInstance(Object)

createTestContextManager

protected TestContextManager createTestContextManager(Class<?> clazz)
Creates a new TestContextManager. Can be overridden by subclasses.

Parameters:
clazz - the Class object corresponding to the test class to be managed
Returns:
a new TestContextManager

getTestContextManager

protected final TestContextManager getTestContextManager()
Gets the TestContextManager associated with this runner.

Returns:
the TestContextManager

invokeTestMethod

protected void invokeTestMethod(Method method,
                                RunNotifier notifier)
Invokes the supplied test method and notifies the supplied RunNotifier of the appropriate events.

Overrides:
invokeTestMethod in class org.junit.internal.runners.JUnit4ClassRunner
See Also:
createTest(), JUnit4ClassRunner.invokeTestMethod(Method,RunNotifier)

The Spring Framework

Copyright © 2002-2007 The Spring Framework.