diff --git a/spring-test/src/main/java/org/springframework/test/context/event/ApplicationEvents.java b/spring-test/src/main/java/org/springframework/test/context/event/ApplicationEvents.java index 3653d4da957e..5bdc8b3c7973 100644 --- a/spring-test/src/main/java/org/springframework/test/context/event/ApplicationEvents.java +++ b/spring-test/src/main/java/org/springframework/test/context/event/ApplicationEvents.java @@ -33,12 +33,14 @@ * to be manually registered if you have custom configuration via * {@link org.springframework.test.context.TestExecutionListeners @TestExecutionListeners} * that does not include the default listeners. - *
  • Annotate a field of type {@code ApplicationEvents} with + *
  • With JUnit Jupiter, declare a parameter of type {@code ApplicationEvents} + * in a test or lifecycle method. Since {@code ApplicationEvents} is scoped to the + * lifecycle of the current test method, this is the recommended approach.
  • + *
  • Alternatively, you can annotate a field of type {@code ApplicationEvents} with * {@link org.springframework.beans.factory.annotation.Autowired @Autowired} and - * use that instance of {@code ApplicationEvents} in your test and lifecycle methods.
  • - *
  • With JUnit Jupiter, you may optionally declare a parameter of type - * {@code ApplicationEvents} in a test or lifecycle method as an alternative to - * an {@code @Autowired} field in the test class.
  • + * use that instance of {@code ApplicationEvents} in your test and lifecycle methods. + * Note that {@code ApplicationEvents} is not a general Spring bean and is specifically + * designed for use within test methods. * * * @author Sam Brannen