java.lang.Object
org.junit.platform.testkit.engine.Event
Event
represents a single event fired during execution of
a test plan on the JUnit Platform.- Since:
- 1.4
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbyTestDescriptor
(Predicate<? super TestDescriptor> testDescriptorPredicate) static Event
dynamicTestRegistered
(TestDescriptor testDescriptor) Create anEvent
for the dynamic registration of the suppliedTestDescriptor
.static Event
executionFinished
(TestDescriptor testDescriptor, TestExecutionResult result) static Event
executionSkipped
(TestDescriptor testDescriptor, String reason) static Event
executionStarted
(TestDescriptor testDescriptor) Create a startedEvent
for the suppliedTestDescriptor
.static Event
fileEntryPublished
(TestDescriptor testDescriptor, FileEntry file) Get the payload, if available.<T> Optional
<T> getPayload
(Class<T> payloadType) Get the payload of the expected type, if available.<T> T
getRequiredPayload
(Class<T> payloadType) Get the payload of the required type.Get theTestDescriptor
associated with thisEvent
.Get theInstant
when thisEvent
occurred.getType()
Get the type of thisEvent
.static Event
reportingEntryPublished
(TestDescriptor testDescriptor, ReportEntry entry) toString()
-
Method Details
-
reportingEntryPublished
- Parameters:
testDescriptor
- theTestDescriptor
associated with the event; nevernull
entry
- theReportEntry
that was published; nevernull
- Returns:
- the newly created
Event
- See Also:
-
fileEntryPublished
@API(status=EXPERIMENTAL, since="1.12") public static Event fileEntryPublished(TestDescriptor testDescriptor, FileEntry file) - Parameters:
testDescriptor
- theTestDescriptor
associated with the event; nevernull
file
- theFileEntry
that was published; nevernull
- Returns:
- the newly created
Event
- Since:
- 1.12
- See Also:
-
dynamicTestRegistered
Create anEvent
for the dynamic registration of the suppliedTestDescriptor
.- Parameters:
testDescriptor
- theTestDescriptor
associated with the event; nevernull
- Returns:
- the newly created
Event
- See Also:
-
executionSkipped
- Parameters:
testDescriptor
- theTestDescriptor
associated with the event; nevernull
reason
- the reason the execution was skipped; may benull
- Returns:
- the newly created
Event
- See Also:
-
executionStarted
Create a startedEvent
for the suppliedTestDescriptor
.- Parameters:
testDescriptor
- theTestDescriptor
associated with the event; nevernull
- Returns:
- the newly created
Event
- See Also:
-
executionFinished
- Parameters:
testDescriptor
- theTestDescriptor
associated with the event; nevernull
result
- theTestExecutionResult
for the suppliedTestDescriptor
; nevernull
- Returns:
- the newly created
Event
- See Also:
-
byPayload
public static <T> Predicate<Event> byPayload(Class<T> payloadType, Predicate<? super T> payloadPredicate) Create aPredicate
for events whose payload types match the suppliedpayloadType
and whose payloads match the suppliedpayloadPredicate
.- Parameters:
payloadType
- the required payload typepayloadPredicate
- aPredicate
to match against payloads- Returns:
- the resulting
Predicate
-
byType
- Parameters:
type
- the type to match against- Returns:
- the resulting
Predicate
-
byTestDescriptor
public static Predicate<Event> byTestDescriptor(Predicate<? super TestDescriptor> testDescriptorPredicate) - Parameters:
testDescriptorPredicate
- aPredicate
to match against test descriptors- Returns:
- the resulting
Predicate
-
getType
Get the type of thisEvent
.- Returns:
- the event type; never
null
- See Also:
-
getTestDescriptor
Get theTestDescriptor
associated with thisEvent
.- Returns:
- the
TestDescriptor
; nevernull
-
getTimestamp
Get theInstant
when thisEvent
occurred.- Returns:
- the
Instant
when thisEvent
occurred; nevernull
-
getPayload
Get the payload, if available.- Returns:
- an
Optional
containing the payload; nevernull
but potentially empty - See Also:
-
getPayload
Get the payload of the expected type, if available.This is a convenience method that automatically casts the payload to the expected type. If the payload is not present or is not of the expected type, this method will return
Optional.empty()
.- Parameters:
payloadType
- the expected payload type; nevernull
- Returns:
- an
Optional
containing the payload; nevernull
but potentially empty - See Also:
-
getRequiredPayload
Get the payload of the required type.This is a convenience method that automatically casts the payload to the required type. If the payload is not present or is not of the expected type, this method will throw an
IllegalArgumentException
.- Parameters:
payloadType
- the required payload type; nevernull
- Returns:
- the payload
- Throws:
IllegalArgumentException
- if the payload is of a different type or is not present- See Also:
-
toString
-