接口 TestExecutionListener

所有已知子接口:
AotTestExecutionListener
所有已知实现类:
AbstractDirtiesContextTestExecutionListener, AbstractTestExecutionListener, ApplicationEventsTestExecutionListener, DependencyInjectionTestExecutionListener, DirtiesContextBeforeModesTestExecutionListener, DirtiesContextTestExecutionListener, EventPublishingTestExecutionListener, MockitoTestExecutionListener, ResetMocksTestExecutionListener, ServletTestExecutionListener, SqlScriptsTestExecutionListener, TransactionalTestExecutionListener

public interface TestExecutionListener
TestExecutionListener defines a listener API for reacting to test execution events published by the TestContextManager with which the listener is registered.

Note that not all testing frameworks support all lifecycle callbacks defined in this API. For example, beforeTestExecution(cn.taketoday.test.context.TestContext) and afterTestExecution(cn.taketoday.test.context.TestContext) are not supported in conjunction with JUnit 4 when using the ApplicationMethodRule.

This interface provides empty default implementations for all methods. Concrete implementations can therefore choose to override only those methods suitable for the task at hand.

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. See TestContextBootstrapper.getTestExecutionListeners() for details.

Registering TestExecutionListener Implementations

A TestExecutionListener can be registered explicitly for a test class, its subclasses, and its nested classes by using the @TestExecutionListeners annotation. Explicit registration is suitable for custom listeners that are used in limited testing scenarios. However, it can become cumbersome if a custom listener needs to be used across an entire test suite. This issue is addressed through support for automatic discovery of default TestExecutionListener implementations through the TodayStrategies mechanism. Specifically, default TestExecutionListener implementations can be registered under the cn.taketoday.test.context.TestExecutionListener key in a TodayStrategies.STRATEGIES_LOCATION properties file.

Infra provides the following implementations. Each of these implements Ordered and is registered automatically by default.

从以下版本开始:
4.0
作者:
Sam Brannen, Juergen Hoeller
另请参阅: