接口 ApplicationEvents

所有已知实现类:
DefaultApplicationEvents

public interface ApplicationEvents
ApplicationEvents encapsulates all application events that were fired during the execution of a single test method.

To use ApplicationEvents in your tests, do the following.

  • Ensure that your test class is annotated or meta-annotated with @RecordApplicationEvents.
  • Ensure that the ApplicationEventsTestExecutionListener is registered. Note, however, that it is registered by default and only needs to be manually registered if you have custom configuration via @TestExecutionListeners that does not include the default listeners.
  • Annotate a field of type ApplicationEvents with @Autowired and use that instance of ApplicationEvents in your test and lifecycle methods.
  • With JUnit Jupiter, you may optionally declare a parameter of type ApplicationEvents in a test or lifecycle method as an alternative to an @Autowired field in the test class.
从以下版本开始:
4.0
作者:
Sam Brannen, Oliver Drotbohm
另请参阅:
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    Clear all application events recorded by this ApplicationEvents instance.
    Stream<cn.taketoday.context.ApplicationEvent>
    Stream all application events that were fired during test execution.
    <T> Stream<T>
    stream(Class<T> type)
    Stream all application events or event payloads of the given type that were fired during test execution.
  • 方法详细资料

    • stream

      Stream<cn.taketoday.context.ApplicationEvent> stream()
      Stream all application events that were fired during test execution.
      返回:
      a stream of all application events
      另请参阅:
    • stream

      <T> Stream<T> stream(Class<T> type)
      Stream all application events or event payloads of the given type that were fired during test execution.
      类型参数:
      T - the event type
      参数:
      type - the type of events or payloads to stream; never null
      返回:
      a stream of all application events or event payloads of the specified type
      另请参阅:
    • clear

      void clear()
      Clear all application events recorded by this ApplicationEvents instance.

      Subsequent calls to stream() or stream(Class) will only include events recorded since this method was invoked.

      另请参阅: