Package org.springframework.test.context.event

# Class TestContextEvent

java.lang.Object
java.util.EventObject
org.springframework.context.ApplicationEvent
org.springframework.test.context.event.TestContextEvent

All Implemented Interfaces:
  `Serializable`

Direct Known Subclasses:
  `AfterTestClassEvent`, `AfterTestExecutionEvent`, `AfterTestMethodEvent`, `BeforeTestClassEvent`, `BeforeTestExecutionEvent`, `BeforeTestMethodEvent`, `PrepareTestInstanceEvent`

public abstract class TestContextEvent extends org.springframework.context.ApplicationEvent
Base class for events published by the `EventPublishingTestExecutionListener`.

Since:
  5.2
Author:
  Frank Scheffler, Sam Brannen
See Also:
  - Serialized Form

## Field Summary

### Fields inherited from class java.util.EventObject

`source`

## Constructor Summary

Constructors
Constructor
Description
`TestContextEvent(TestContext source)`
Create a new `TestContextEvent`.

## Method Summary

Modifier and Type
Method
Description
`final TestContext`
`getSource()`
Get the `TestContext` associated with this event.
`final TestContext`
`getTestContext()`
Alias for `getSource()`.

### Methods inherited from class org.springframework.context.ApplicationEvent

`getTimestamp`

### Methods inherited from class java.util.EventObject

`toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### TestContextEvent

public TestContextEvent(TestContext source)
Create a new `TestContextEvent`.

Parameters:
  `source` - the `TestContext` associated with this event (must not be `null`)

## Method Details

### getSource

public final TestContext getSource()
Get the `TestContext` associated with this event.

Overrides:
  `getSource` in class `EventObject`
Returns:
  the `TestContext` associated with this event (never `null`)
See Also:
  - `getTestContext()`

### getTestContext

public final TestContext getTestContext()
Alias for `getSource()`.

This method may be favored over `getSource()` — for example, to improve readability in SpEL expressions for event processing conditions.

Returns:
  the `TestContext` associated with this event (never `null`)
See Also:
  - `getSource()`