Class Events
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
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaborted()
Get the abortedEvents
contained in thisEvents
object.private static void
assertEventsMatchExactly
(List<Event> events, org.assertj.core.api.Condition<? super Event>... conditions) final void
assertEventsMatchExactly
(org.assertj.core.api.Condition<? super Event>... conditions) Assert that all events contained in thisEvents
object exactly match the provided conditions.private static void
assertEventsMatchLoosely
(List<Event> events, org.assertj.core.api.Condition<? super Event>... conditions) final void
assertEventsMatchLoosely
(org.assertj.core.api.Condition<? super Event>... conditions) Assert that all provided conditions are matched by an event contained in thisEvents
object, regardless of order.private static void
assertEventsMatchLooselyInOrder
(List<Event> events, org.assertj.core.api.Condition<? super Event>... conditions) final void
assertEventsMatchLooselyInOrder
(org.assertj.core.api.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.org.assertj.core.api.ListAssert
<Event> Shortcut fororg.assertj.core.api.Assertions.assertThat(events.list())
.private static void
checkCondition
(List<Event> events, org.assertj.core.api.SoftAssertions softly, org.assertj.core.api.Condition<? super Event> condition) 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
.private Events
debug
(PrintWriter printWriter) Print all events to the suppliedWriter
.Get the dynamic registrationEvents
contained in thisEvents
object.eventsByType
(EventType type) Get theExecutions
for the current set of events.failed()
Get the failedEvents
contained in thisEvents
object.Shortcut forevents.stream().filter(predicate)
.private static Event
findEvent
(List<Event> events, org.assertj.core.api.SoftAssertions softly, org.assertj.core.api.Condition<? super Event> condition) finished()
Get the finishedEvents
contained in thisEvents
object.(package private) String
private static boolean
isNotInIncreasingOrder
(List<Integer> indices) 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.
-
Field Details
-
events
-
category
-
-
Constructor Details
-
Events
-
Events
-
-
Method Details
-
getCategory
String getCategory() -
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
@SafeVarargs public final void assertEventsMatchExactly(org.assertj.core.api.Condition<? super Event>... conditions) 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
@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 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(org.assertj.core.api.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
-
debug
-
eventsByType
-
finishedEventsByStatus
-
assertEventsMatchExactly
@SafeVarargs private static void assertEventsMatchExactly(List<Event> events, org.assertj.core.api.Condition<? super Event>... conditions) -
assertEventsMatchLoosely
@SafeVarargs private static void assertEventsMatchLoosely(List<Event> events, org.assertj.core.api.Condition<? super Event>... conditions) -
assertEventsMatchLooselyInOrder
@SafeVarargs private static void assertEventsMatchLooselyInOrder(List<Event> events, org.assertj.core.api.Condition<? super Event>... conditions) -
isNotInIncreasingOrder
-
checkCondition
-
findEvent
-