spring-framework / org.springframework.test.context.support / DefaultTestContext

DefaultTestContext

open class DefaultTestContext : TestContext

Default implementation of the TestContext interface.

Author
Sam Brannen

Author
Juergen Hoeller

Author
Rob Harrop

Since
4.0

Constructors

<init>

DefaultTestContext(testContext: DefaultTestContext)

Copy constructor for creating a new DefaultTestContext based on the attributes and immutable state of the supplied context.

Immutable state includes all arguments supplied to the standard constructor.

DefaultTestContext(testClass: Class<*>, mergedContextConfiguration: MergedContextConfiguration, cacheAwareContextLoaderDelegate: CacheAwareContextLoaderDelegate)

Construct a new DefaultTestContext from the supplied arguments.

Functions

attributeNames

open fun attributeNames(): Array<String>

getApplicationContext

open fun getApplicationContext(): ApplicationContext

Get the ApplicationContext for this test context.

The default implementation delegates to the CacheAwareContextLoaderDelegate that was supplied when this TestContext was constructed.

getAttribute

open fun getAttribute(name: String): Any

getTestClass

fun getTestClass(): Class<*>

getTestException

fun getTestException(): Throwable

getTestInstance

fun getTestInstance(): Any

getTestMethod

fun getTestMethod(): Method

hasAttribute

open fun hasAttribute(name: String): Boolean

markApplicationContextDirty

open fun markApplicationContextDirty(hierarchyMode: HierarchyMode): Unit

Mark the ApplicationContext associated with this test context as dirty (i.e., by removing it from the context cache and closing it).

The default implementation delegates to the CacheAwareContextLoaderDelegate that was supplied when this TestContext was constructed.

removeAttribute

open fun removeAttribute(name: String): Any

setAttribute

open fun setAttribute(name: String, value: Any): Unit

toString

open fun toString(): String

Provide a String representation of this test context's state.

updateState

open fun updateState(testInstance: Any, testMethod: Method, testException: Throwable): Unit