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()
Deprecated.
as of Spring 3.2.2; use
markApplicationContextDirty(DirtiesContext.HierarchyMode) instead. |
void |
markApplicationContextDirty(DirtiesContext.HierarchyMode hierarchyMode)
Call this method to signal that the application
context associated with this test context is dirty and should be
discarded.
|
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 Class<?> getTestClass()
test class for this test context.null)public Object getTestInstance()
test instance for this test context.
Note: this is a mutable property.
null)updateState(Object, Method, Throwable)public Method getTestMethod()
test method for this test context.
Note: this is a mutable property.
null)updateState(Object, Method, Throwable)public 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)@Deprecated public void markApplicationContextDirty()
markApplicationContextDirty(DirtiesContext.HierarchyMode) instead.public void markApplicationContextDirty(DirtiesContext.HierarchyMode hierarchyMode)
hierarchyMode - the context cache clearing mode to be applied if the
context is part of a hierarchy (may be null)