Class Event
- java.lang.Object
-
- org.junit.platform.testkit.engine.Event
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> Predicate<Event>
byPayload(Class<T> payloadType, Predicate<? super T> payloadPredicate)
static Predicate<Event>
byTestDescriptor(Predicate<? super TestDescriptor> testDescriptorPredicate)
static Predicate<Event>
byType(EventType type)
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
.Optional<Object>
getPayload()
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.TestDescriptor
getTestDescriptor()
Get theTestDescriptor
associated with thisEvent
.Instant
getTimestamp()
Get theInstant
when thisEvent
occurred.EventType
getType()
Get the type of thisEvent
.static Event
reportingEntryPublished(TestDescriptor testDescriptor, ReportEntry entry)
String
toString()
-
-
-
Method Detail
-
reportingEntryPublished
public static Event reportingEntryPublished(TestDescriptor testDescriptor, ReportEntry entry)
- Parameters:
testDescriptor
- theTestDescriptor
associated with the event; nevernull
entry
- theReportEntry
that was published; nevernull
- Returns:
- the newly created
Event
- See Also:
EventType.REPORTING_ENTRY_PUBLISHED
-
dynamicTestRegistered
public static Event dynamicTestRegistered(TestDescriptor testDescriptor)
Create anEvent
for the dynamic registration of the suppliedTestDescriptor
.- Parameters:
testDescriptor
- theTestDescriptor
associated with the event; nevernull
- Returns:
- the newly created
Event
- See Also:
EventType.DYNAMIC_TEST_REGISTERED
-
executionSkipped
public static Event executionSkipped(TestDescriptor testDescriptor, String reason)
- Parameters:
testDescriptor
- theTestDescriptor
associated with the event; nevernull
reason
- the reason the execution was skipped; may benull
- Returns:
- the newly created
Event
- See Also:
EventType.SKIPPED
-
executionStarted
public static Event executionStarted(TestDescriptor testDescriptor)
Create a startedEvent
for the suppliedTestDescriptor
.- Parameters:
testDescriptor
- theTestDescriptor
associated with the event; nevernull
- Returns:
- the newly created
Event
- See Also:
EventType.STARTED
-
executionFinished
public static Event executionFinished(TestDescriptor testDescriptor, TestExecutionResult result)
- Parameters:
testDescriptor
- theTestDescriptor
associated with the event; nevernull
result
- theTestExecutionResult
for the suppliedTestDescriptor
; nevernull
- Returns:
- the newly created
Event
- See Also:
EventType.FINISHED
-
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
public static Predicate<Event> byType(EventType type)
- 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
public EventType getType()
Get the type of thisEvent
.- Returns:
- the event type; never
null
- See Also:
EventType
-
getTestDescriptor
public TestDescriptor getTestDescriptor()
Get theTestDescriptor
associated with thisEvent
.- Returns:
- the
TestDescriptor
; nevernull
-
getTimestamp
public Instant getTimestamp()
Get theInstant
when thisEvent
occurred.- Returns:
- the
Instant
when thisEvent
occurred; nevernull
-
getPayload
public Optional<Object> getPayload()
Get the payload, if available.- Returns:
- an
Optional
containing the payload; nevernull
but potentially empty - See Also:
getPayload(Class)
,getRequiredPayload(Class)
-
getPayload
public <T> Optional<T> getPayload(Class<T> payloadType)
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:
getPayload()
,getRequiredPayload(Class)
-
getRequiredPayload
public <T> T getRequiredPayload(Class<T> payloadType) throws IllegalArgumentException
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:
getPayload()
,getPayload(Class)
-
-