Class Events
- java.lang.Object
-
- org.junit.platform.testkit.engine.Events
-
@API(status=MAINTAINED, since="1.7") public final class Events extends java.lang.ObjectEventsis a facade that provides a fluent API for working with events.- Since:
- 1.4
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Eventsaborted()Get the abortedEventscontained in thisEventsobject.private static voidassertEventsMatchExactly(java.util.List<Event> events, org.assertj.core.api.Condition<? super Event>... conditions)voidassertEventsMatchExactly(org.assertj.core.api.Condition<? super Event>... conditions)Assert that all events contained in thisEventsobject exactly match the provided conditions.private static voidassertEventsMatchLoosely(java.util.List<Event> events, org.assertj.core.api.Condition<? super Event>... conditions)voidassertEventsMatchLoosely(org.assertj.core.api.Condition<? super Event>... conditions)Assert that all provided conditions are matched by an event contained in thisEventsobject, regardless of order.private static voidassertEventsMatchLooselyInOrder(java.util.List<Event> events, org.assertj.core.api.Condition<? super Event>... conditions)voidassertEventsMatchLooselyInOrder(org.assertj.core.api.Condition<? super Event>... conditions)Assert that all provided conditions are matched by an event contained in thisEventsobject.EventsassertStatistics(java.util.function.Consumer<EventStatistics> statisticsConsumer)Assert statistics for the events contained in thisEventsobject.org.assertj.core.api.ListAssert<Event>assertThatEvents()Shortcut fororg.assertj.core.api.Assertions.assertThat(events.list()).private static voidcheckCondition(java.util.List<Event> events, org.assertj.core.api.SoftAssertions softly, org.assertj.core.api.Condition<? super Event> condition)longcount()Get the number of events contained in thisEventsobject.Eventsdebug()Print all events toSystem.out.Eventsdebug(java.io.OutputStream out)Print all events to the suppliedOutputStream.private Eventsdebug(java.io.PrintWriter printWriter)Eventsdebug(java.io.Writer writer)Print all events to the suppliedWriter.EventsdynamicallyRegistered()Get the dynamic registrationEventscontained in thisEventsobject.private java.util.stream.Stream<Event>eventsByType(EventType type)Executionsexecutions()Get theExecutionsfor the current set of events.Eventsfailed()Get the failedEventscontained in thisEventsobject.java.util.stream.Stream<Event>filter(java.util.function.Predicate<? super Event> predicate)Shortcut forevents.stream().filter(predicate).private static EventfindEvent(java.util.List<Event> events, org.assertj.core.api.SoftAssertions softly, org.assertj.core.api.Condition<? super Event> condition)Eventsfinished()Get the finishedEventscontained in thisEventsobject.private java.util.stream.Stream<Event>finishedEventsByStatus(TestExecutionResult.Status status)(package private) java.lang.StringgetCategory()private static booleanisNotInIncreasingOrder(java.util.List<java.lang.Integer> indices)java.util.List<Event>list()Get the events as aList.<R> java.util.stream.Stream<R>map(java.util.function.Function<? super Event,? extends R> mapper)Shortcut forevents.stream().map(mapper).EventsreportingEntryPublished()Get the reporting entry publicationEventscontained in thisEventsobject.Eventsskipped()Get the skippedEventscontained in thisEventsobject.Eventsstarted()Get the startedEventscontained in thisEventsobject.java.util.stream.Stream<Event>stream()Get the events as aStream.Eventssucceeded()Get the succeededEventscontained in thisEventsobject.
-
-
-
Field Detail
-
events
private final java.util.List<Event> events
-
category
private final java.lang.String category
-
-
Method Detail
-
getCategory
java.lang.String getCategory()
-
list
public java.util.List<Event> list()
Get the events as aList.- Returns:
- the list of events; never
null - See Also:
stream()
-
stream
public java.util.stream.Stream<Event> stream()
Get the events as aStream.- Returns:
- the stream of events; never
null - See Also:
list()
-
map
public <R> java.util.stream.Stream<R> map(java.util.function.Function<? super Event,? extends R> mapper)
Shortcut forevents.stream().map(mapper).- Parameters:
mapper- aFunctionto apply to each event; nevernull- Returns:
- the mapped stream of events; never
null - See Also:
stream(),Stream.map(Function)
-
filter
public java.util.stream.Stream<Event> filter(java.util.function.Predicate<? super Event> predicate)
Shortcut forevents.stream().filter(predicate).- Parameters:
predicate- aPredicateto apply to each event to decide if it should be included in the filtered stream; nevernull- Returns:
- the filtered stream of events; never
null - See Also:
stream(),Stream.filter(Predicate)
-
executions
public Executions executions()
Get theExecutionsfor the current set of events.- Returns:
- an instance of
Executionsfor the current set of events; nevernull
-
count
public long count()
Get the number of events contained in thisEventsobject.
-
skipped
public Events skipped()
Get the skippedEventscontained in thisEventsobject.- Returns:
- the filtered
Events; nevernull
-
started
public Events started()
Get the startedEventscontained in thisEventsobject.- Returns:
- the filtered
Events; nevernull
-
finished
public Events finished()
Get the finishedEventscontained in thisEventsobject.- Returns:
- the filtered
Events; nevernull
-
aborted
public Events aborted()
Get the abortedEventscontained in thisEventsobject.- Returns:
- the filtered
Events; nevernull
-
succeeded
public Events succeeded()
Get the succeededEventscontained in thisEventsobject.- Returns:
- the filtered
Events; nevernull
-
failed
public Events failed()
Get the failedEventscontained in thisEventsobject.- Returns:
- the filtered
Events; nevernull
-
reportingEntryPublished
public Events reportingEntryPublished()
Get the reporting entry publicationEventscontained in thisEventsobject.- Returns:
- the filtered
Events; nevernull
-
dynamicallyRegistered
public Events dynamicallyRegistered()
Get the dynamic registrationEventscontained in thisEventsobject.- Returns:
- the filtered
Events; nevernull
-
assertStatistics
public Events assertStatistics(java.util.function.Consumer<EventStatistics> statisticsConsumer)
Assert statistics for the events contained in thisEventsobject.Example
events.assertStatistics(stats -> stats.started(1).succeeded(1).failed(0));- Parameters:
statisticsConsumer- aConsumerofEventStatistics; nevernull- Returns:
- this
Eventsobject for method chaining; nevernull
-
assertEventsMatchExactly
@SafeVarargs public final void assertEventsMatchExactly(org.assertj.core.api.Condition<? super Event>... conditions)
Assert that all events contained in thisEventsobject exactly match the provided conditions.Conditions can be imported statically from
EventConditionsandTestExecutionResultConditions.Example
executionResults.testEvents().assertEventsMatchExactly( event(test("exampleTestMethod"), started()), event(test("exampleTestMethod"), finishedSuccessfully()) );- Parameters:
conditions- the conditions to match against; nevernull- See Also:
assertEventsMatchLoosely(Condition...),assertEventsMatchLooselyInOrder(Condition...),EventConditions,TestExecutionResultConditions
-
assertEventsMatchLoosely
@SafeVarargs public final void assertEventsMatchLoosely(org.assertj.core.api.Condition<? super Event>... conditions)
Assert that all provided conditions are matched by an event contained in thisEventsobject, regardless of order.Note that this method performs a partial match. Thus, some events may not match any of the provided conditions.
Conditions can be imported statically from
EventConditionsandTestExecutionResultConditions.Example
executionResults.testEvents().assertEventsMatchLoosely( event(test("exampleTestMethod"), started()), event(test("exampleTestMethod"), finishedSuccessfully()) );- Parameters:
conditions- the conditions to match against; nevernull- Since:
- 1.7
- See Also:
assertEventsMatchExactly(Condition...),assertEventsMatchLooselyInOrder(Condition...),EventConditions,TestExecutionResultConditions
-
assertEventsMatchLooselyInOrder
@SafeVarargs public final void assertEventsMatchLooselyInOrder(org.assertj.core.api.Condition<? super Event>... conditions)
Assert that all provided conditions are matched by an event contained in thisEventsobject.Note that this method performs a partial match. Thus, some events may not match any of the provided conditions; however, the conditions provided must be in the correct order.
Conditions can be imported statically from
EventConditionsandTestExecutionResultConditions.Example
executionResults.testEvents().assertEventsMatchLooselyInOrder( event(test("exampleTestMethod"), started()), event(test("exampleTestMethod"), finishedSuccessfully()) );- Parameters:
conditions- the conditions to match against; nevernull- Since:
- 1.7
- See Also:
assertEventsMatchExactly(Condition...),assertEventsMatchLoosely(Condition...),EventConditions,TestExecutionResultConditions
-
assertThatEvents
public org.assertj.core.api.ListAssert<Event> assertThatEvents()
Shortcut fororg.assertj.core.api.Assertions.assertThat(events.list()).- Returns:
- an instance of
ListAssertfor events; nevernull - See Also:
Assertions.assertThat(List),ListAssert
-
debug
public Events debug()
Print all events toSystem.out.- Returns:
- this
Eventsobject for method chaining; nevernull
-
debug
public Events debug(java.io.OutputStream out)
Print all events to the suppliedOutputStream.- Parameters:
out- theOutputStreamto print to; nevernull- Returns:
- this
Eventsobject for method chaining; nevernull
-
debug
public Events debug(java.io.Writer writer)
Print all events to the suppliedWriter.- Parameters:
writer- theWriterto print to; nevernull- Returns:
- this
Eventsobject for method chaining; nevernull
-
debug
private Events debug(java.io.PrintWriter printWriter)
-
finishedEventsByStatus
private java.util.stream.Stream<Event> finishedEventsByStatus(TestExecutionResult.Status status)
-
assertEventsMatchExactly
@SafeVarargs private static void assertEventsMatchExactly(java.util.List<Event> events, org.assertj.core.api.Condition<? super Event>... conditions)
-
assertEventsMatchLoosely
@SafeVarargs private static void assertEventsMatchLoosely(java.util.List<Event> events, org.assertj.core.api.Condition<? super Event>... conditions)
-
assertEventsMatchLooselyInOrder
@SafeVarargs private static void assertEventsMatchLooselyInOrder(java.util.List<Event> events, org.assertj.core.api.Condition<? super Event>... conditions)
-
isNotInIncreasingOrder
private static boolean isNotInIncreasingOrder(java.util.List<java.lang.Integer> indices)
-
checkCondition
private static void checkCondition(java.util.List<Event> events, org.assertj.core.api.SoftAssertions softly, org.assertj.core.api.Condition<? super Event> condition)
-
-