接口 TestExecutionListener
- 所有已知实现类:
AbstractDirtiesContextTestExecutionListener
,AbstractTestExecutionListener
,DependencyInjectionTestExecutionListener
,DirtiesContextBeforeModesTestExecutionListener
,DirtiesContextTestExecutionListener
,ServletTestExecutionListener
,SqlScriptsTestExecutionListener
,TransactionalTestExecutionListener
public interface TestExecutionListener
TestExecutionListener
defines a listener API for reacting to test execution events published by theTestContextManager
with which the listener is registered.Concrete implementations must provide a
public
no-args constructor, so that listeners can be instantiated transparently by tools and configuration mechanisms.Implementations may optionally declare the position in which they should be ordered among the chain of default listeners via the
Ordered
interface or@Order
annotation. SeeTestContextBootstrapper.getTestExecutionListeners()
for details.Spring provides the following out-of-the-box implementations (all of which implement
Ordered
):- 从以下版本开始:
- 2.5
- 作者:
- Sam Brannen, Juergen Hoeller
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 void
afterTestClass(TestContext testContext)
Post-processes a test class after execution of all tests within the class.void
afterTestMethod(TestContext testContext)
Post-processes a test after execution of thetest method
in the suppliedtest context
, for example by tearing down test fixtures.void
beforeTestClass(TestContext testContext)
Pre-processes a test class before execution of all tests within the class.void
beforeTestMethod(TestContext testContext)
Pre-processes a test before execution of thetest method
in the suppliedtest context
, for example by setting up test fixtures.void
prepareTestInstance(TestContext testContext)
Prepares thetest instance
of the suppliedtest context
, for example by injecting dependencies.
方法详细资料
beforeTestClass
void beforeTestClass(TestContext testContext) throws Exception
Pre-processes a test class before execution of all tests within the class.This method should be called immediately before framework-specific before class lifecycle callbacks.
If a given testing framework does not support before class lifecycle callbacks, this method will not be called for that framework.
- 参数:
testContext
- the test context for the test; nevernull
- 抛出:
Exception
- allows any exception to propagate
prepareTestInstance
void prepareTestInstance(TestContext testContext) throws Exception
Prepares thetest instance
of the suppliedtest context
, for example by injecting dependencies.This method should be called immediately after instantiation of the test instance but prior to any framework-specific lifecycle callbacks.
- 参数:
testContext
- the test context for the test; nevernull
- 抛出:
Exception
- allows any exception to propagate
beforeTestMethod
void beforeTestMethod(TestContext testContext) throws Exception
Pre-processes a test before execution of thetest method
in the suppliedtest context
, for example by setting up test fixtures.This method should be called immediately prior to framework-specific before lifecycle callbacks.
- 参数:
testContext
- the test context in which the test method will be executed; nevernull
- 抛出:
Exception
- allows any exception to propagate
afterTestMethod
void afterTestMethod(TestContext testContext) throws Exception
Post-processes a test after execution of thetest method
in the suppliedtest context
, for example by tearing down test fixtures.This method should be called immediately after framework-specific after lifecycle callbacks.
- 参数:
testContext
- the test context in which the test method was executed; nevernull
- 抛出:
Exception
- allows any exception to propagate
afterTestClass
void afterTestClass(TestContext testContext) throws Exception
Post-processes a test class after execution of all tests within the class.This method should be called immediately after framework-specific after class lifecycle callbacks.
If a given testing framework does not support after class lifecycle callbacks, this method will not be called for that framework.
- 参数:
testContext
- the test context for the test; nevernull
- 抛出:
Exception
- allows any exception to propagate