Class Events
- java.lang.Object
-
- org.junit.platform.testkit.engine.Events
-
@API(status=EXPERIMENTAL, since="1.4") 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.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()).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).Eventsfinished()Get the finishedEventscontained in thisEventsobject.private java.util.stream.Stream<Event>finishedEventsByStatus(TestExecutionResult.Status status)(package private) java.lang.StringgetCategory()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.tests().assertEventsMatchExactly( event(test("exampleTestMethod"), started()), event(test("exampleTestMethod"), finishedSuccessfully()) );- Parameters:
conditions- the conditions to match against; nevernull- See Also:
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)
-
-