| 
The Spring Framework | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.core.AttributeAccessorSupport
org.springframework.test.context.TestContext
public class TestContext
TestContext encapsulates the context in which a test is executed, agnostic of the actual testing framework in use.
| Constructor Summary | |
|---|---|
TestContext(Class<?> testClass,
            org.springframework.test.context.ContextCache<String,ApplicationContext> contextCache)
Constructs a new test context for the supplied test class
 and context cache and parses the corresponding
 @ContextConfiguration annotation, if
 present. | 
|
| Method Summary | |
|---|---|
 ApplicationContext | 
getApplicationContext()
Gets the application context for this test
 context, possibly cached. | 
 Class<?> | 
getTestClass()
Gets the test class for this test context. | 
 Throwable | 
getTestException()
Gets the exception that was thrown during execution of
 the test method. | 
 Object | 
getTestInstance()
Gets the current test instance for this test context. | 
 Method | 
getTestMethod()
Gets the current test method for this test context. | 
 void | 
markApplicationContextDirty()
Call this method to signal that the application context associated with this test
 context is dirty and should be reloaded. | 
 String | 
toString()
Provides a string representation of this test context's test class,
 application context resource locations,
 test instance,
 test method, and
 test exception. | 
| Methods inherited from class org.springframework.core.AttributeAccessorSupport | 
|---|
attributeNames, copyAttributesFrom, equals, getAttribute, hasAttribute, hashCode, removeAttribute, setAttribute | 
| Methods inherited from class java.lang.Object | 
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait | 
| Constructor Detail | 
|---|
public TestContext(Class<?> testClass,
                   org.springframework.test.context.ContextCache<String,ApplicationContext> contextCache)
test class
 and context cache and parses the corresponding
 @ContextConfiguration annotation, if
 present.
testClass - the Class object corresponding to the test class
        for which the test context should be constructed; must not be
        null.contextCache - the context cache from which the constructed test
        context should retrieve application contexts; must not be
        null.| Method Detail | 
|---|
public ApplicationContext getApplicationContext()
                                         throws Exception
 Gets the application context for this test
 context, possibly cached.
 
null if the
         current test context is not configured to use an application
         context.
Exception - if an error occurs while retrieving the application
         context.public final Class<?> getTestClass()
 Gets the test class for this test context.
 
null.public final Object getTestInstance()
 Gets the current test instance for this test context.
 
Note: this is a mutable property.
null.updateState(Object,Method,Throwable)public final Method getTestMethod()
 Gets the current test method for this test context.
 
Note: this is a mutable property.
null.updateState(Object,Method,Throwable)public final Throwable getTestException()
 Gets the exception that was thrown during execution of
 the test method.
 
Note: this is a mutable property.
null if no
         exception was thrown.updateState(Object,Method,Throwable)public void markApplicationContextDirty()
application context associated with this test
 context is dirty and should be reloaded. Do this if a test has
 modified the context (for example, by replacing a bean definition).
public String toString()
test class,
 application context resource locations,
 test instance,
 test method, and
 test exception.
toString in class Object
  | 
The Spring Framework | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||