java.lang.Object
org.junit.platform.testkit.engine.Events
Events
is a facade that provides a fluent API for working with
events.- Since:
- 1.4
-
Method Summary
Modifier and TypeMethodDescriptionaborted()
Get the abortedEvents
contained in thisEvents
object.final void
assertEventsMatchExactly
(Condition<? super Event>... conditions) Assert that all events contained in thisEvents
object exactly match the provided conditions.final void
assertEventsMatchLoosely
(Condition<? super Event>... conditions) Assert that all provided conditions are matched by an event contained in thisEvents
object, regardless of order.final void
assertEventsMatchLooselyInOrder
(Condition<? super Event>... conditions) Assert that all provided conditions are matched by an event contained in thisEvents
object.assertStatistics
(Consumer<EventStatistics> statisticsConsumer) Assert statistics for the events contained in thisEvents
object.Shortcut fororg.assertj.core.api.Assertions.assertThat(events.list())
.long
count()
Get the number of events contained in thisEvents
object.debug()
Print all events toSystem.out
.debug
(OutputStream out) Print all events to the suppliedOutputStream
.Print all events to the suppliedWriter
.Get the dynamic registrationEvents
contained in thisEvents
object.Get theExecutions
for the current set of events.failed()
Get the failedEvents
contained in thisEvents
object.Shortcut forevents.stream().filter(predicate)
.finished()
Get the finishedEvents
contained in thisEvents
object.list()
<R> Stream<R>
Shortcut forevents.stream().map(mapper)
.Get the reporting entry publicationEvents
contained in thisEvents
object.skipped()
Get the skippedEvents
contained in thisEvents
object.started()
Get the startedEvents
contained in thisEvents
object.stream()
Get the succeededEvents
contained in thisEvents
object.
-
Method Details
-
list
- Returns:
- the list of events; never
null
- See Also:
-
stream
- Returns:
- the stream of events; never
null
- See Also:
-
map
Shortcut forevents.stream().map(mapper)
.- Parameters:
mapper
- aFunction
to apply to each event; nevernull
- Returns:
- the mapped stream of events; never
null
- See Also:
-
filter
Shortcut forevents.stream().filter(predicate)
.- Parameters:
predicate
- aPredicate
to 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:
-
executions
Get theExecutions
for the current set of events.- Returns:
- an instance of
Executions
for the current set of events; nevernull
-
count
public long count()Get the number of events contained in thisEvents
object. -
skipped
Get the skippedEvents
contained in thisEvents
object.- Returns:
- the filtered
Events
; nevernull
-
started
Get the startedEvents
contained in thisEvents
object.- Returns:
- the filtered
Events
; nevernull
-
finished
Get the finishedEvents
contained in thisEvents
object.- Returns:
- the filtered
Events
; nevernull
-
aborted
Get the abortedEvents
contained in thisEvents
object.- Returns:
- the filtered
Events
; nevernull
-
succeeded
Get the succeededEvents
contained in thisEvents
object.- Returns:
- the filtered
Events
; nevernull
-
failed
Get the failedEvents
contained in thisEvents
object.- Returns:
- the filtered
Events
; nevernull
-
reportingEntryPublished
Get the reporting entry publicationEvents
contained in thisEvents
object.- Returns:
- the filtered
Events
; nevernull
-
dynamicallyRegistered
Get the dynamic registrationEvents
contained in thisEvents
object.- Returns:
- the filtered
Events
; nevernull
-
assertStatistics
Assert statistics for the events contained in thisEvents
object.Example
events.assertStatistics(stats -> stats.started(1).succeeded(1).failed(0));
- Parameters:
statisticsConsumer
- aConsumer
ofEventStatistics
; nevernull
- Returns:
- this
Events
object for method chaining; nevernull
-
assertEventsMatchExactly
Assert that all events contained in thisEvents
object exactly match the provided conditions.Conditions can be imported statically from
EventConditions
andTestExecutionResultConditions
.Example
executionResults.testEvents().assertEventsMatchExactly( event(test("exampleTestMethod"), started()), event(test("exampleTestMethod"), finishedSuccessfully()) );
- Parameters:
conditions
- the conditions to match against; nevernull
- See Also:
-
assertEventsMatchLoosely
Assert that all provided conditions are matched by an event contained in thisEvents
object, 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
EventConditions
andTestExecutionResultConditions
.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:
-
assertEventsMatchLooselyInOrder
@SafeVarargs public final void assertEventsMatchLooselyInOrder(Condition<? super Event>... conditions) Assert that all provided conditions are matched by an event contained in thisEvents
object.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
EventConditions
andTestExecutionResultConditions
.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:
-
assertThatEvents
Shortcut fororg.assertj.core.api.Assertions.assertThat(events.list())
.- Returns:
- an instance of
ListAssert
for events; nevernull
- See Also:
-
debug
Print all events toSystem.out
.- Returns:
- this
Events
object for method chaining; nevernull
-
debug
Print all events to the suppliedOutputStream
.- Parameters:
out
- theOutputStream
to print to; nevernull
- Returns:
- this
Events
object for method chaining; nevernull
-
debug
Print all events to the suppliedWriter
.- Parameters:
writer
- theWriter
to print to; nevernull
- Returns:
- this
Events
object for method chaining; nevernull
-