public class TestContext extends AttributeAccessorSupport
TestContext encapsulates the context in which a test is executed,
agnostic of the actual testing framework in use.| Modifier and Type | Method and Description |
|---|---|
ApplicationContext |
getApplicationContext()
Get the
application context for this test
context, possibly cached. |
Class<?> |
getTestClass()
Get the
test class for this test context. |
Throwable |
getTestException()
Get the
exception that was thrown during execution of
the test method. |
Object |
getTestInstance()
Get the current
test instance for this test context. |
Method |
getTestMethod()
Get 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()
Provide a String representation of this test context's state.
|
attributeNames, copyAttributesFrom, equals, getAttribute, hasAttribute, hashCode, removeAttribute, setAttributepublic ApplicationContext getApplicationContext()
application context for this test
context, possibly cached.IllegalStateException - if an error occurs while retrieving the
application contextpublic final Class<?> getTestClass()
test class for this test context.null)public final Object getTestInstance()
test instance for this test context.
Note: this is a mutable property.
null)updateState(Object,Method,Throwable)public final Method getTestMethod()
test method for this test context.
Note: this is a mutable property.
null)updateState(Object, Method, Throwable)public final Throwable getTestException()
exception that was thrown during execution of
the test method.
Note: this is a mutable property.
null if no
exception was thrownupdateState(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).