public interface

TestExecutionListener

org.springframework.test.context.TestExecutionListener
Known Indirect Subclasses

Class Overview

TestExecutionListener defines a listener API for reacting to test execution events published by the TestContextManager 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.

Spring provides the following out-of-the-box implementations:

Summary

Public Methods
abstract void afterTestClass(TestContext testContext)
Post-processes a test class after execution of all tests within the class.
abstract void afterTestMethod(TestContext testContext)
Post-processes a test after execution of the test method in the supplied test context, for example by tearing down test fixtures.
abstract void beforeTestClass(TestContext testContext)
Pre-processes a test class before execution of all tests within the class.
abstract void beforeTestMethod(TestContext testContext)
Pre-processes a test before execution of the test method in the supplied test context, for example by setting up test fixtures.
abstract void prepareTestInstance(TestContext testContext)
Prepares the test instance of the supplied test context, for example by injecting dependencies.

Public Methods

public abstract void afterTestClass (TestContext testContext)

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 (e.g., JUnit 3.8) does not support after class lifecycle callbacks, this method will not be called for that framework.

Parameters
testContext the test context for the test; never null
Throws
Exception allows any exception to propagate

public abstract void afterTestMethod (TestContext testContext)

Post-processes a test after execution of the test method in the supplied test context, for example by tearing down test fixtures.

This method should be called immediately after framework-specific after lifecycle callbacks.

Parameters
testContext the test context in which the test method was executed; never null
Throws
Exception allows any exception to propagate

public abstract void beforeTestClass (TestContext testContext)

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 (e.g., JUnit 3.8) does not support before class lifecycle callbacks, this method will not be called for that framework.

Parameters
testContext the test context for the test; never null
Throws
Exception allows any exception to propagate

public abstract void beforeTestMethod (TestContext testContext)

Pre-processes a test before execution of the test method in the supplied test context, for example by setting up test fixtures.

This method should be called immediately prior to framework-specific before lifecycle callbacks.

Parameters
testContext the test context in which the test method will be executed; never null
Throws
Exception allows any exception to propagate

public abstract void prepareTestInstance (TestContext testContext)

Prepares the test instance of the supplied test 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.

Parameters
testContext the test context for the test; never null
Throws
Exception allows any exception to propagate