- 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 EventdynamicTestRegistered(TestDescriptor testDescriptor)Create anEventfor the dynamic registration of the suppliedTestDescriptor.static EventexecutionFinished(TestDescriptor testDescriptor, TestExecutionResult result)static EventexecutionSkipped(TestDescriptor testDescriptor, String reason)static EventexecutionStarted(TestDescriptor testDescriptor)Create a startedEventfor 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> TgetRequiredPayload(Class<T> payloadType)Get the payload of the required type.TestDescriptorgetTestDescriptor()Get theTestDescriptorassociated with thisEvent.InstantgetTimestamp()Get theInstantwhen thisEventoccurred.EventTypegetType()Get the type of thisEvent.static EventreportingEntryPublished(TestDescriptor testDescriptor, ReportEntry entry)StringtoString()
-
-
-
Method Detail
-
reportingEntryPublished
public static Event reportingEntryPublished(TestDescriptor testDescriptor, ReportEntry entry)
- Parameters:
testDescriptor- theTestDescriptorassociated with the event; nevernullentry- theReportEntrythat was published; nevernull- Returns:
- the newly created
Event - See Also:
EventType.REPORTING_ENTRY_PUBLISHED
-
dynamicTestRegistered
public static Event dynamicTestRegistered(TestDescriptor testDescriptor)
Create anEventfor the dynamic registration of the suppliedTestDescriptor.- Parameters:
testDescriptor- theTestDescriptorassociated 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- theTestDescriptorassociated with the event; nevernullreason- 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 startedEventfor the suppliedTestDescriptor.- Parameters:
testDescriptor- theTestDescriptorassociated with the event; nevernull- Returns:
- the newly created
Event - See Also:
EventType.STARTED
-
executionFinished
public static Event executionFinished(TestDescriptor testDescriptor, TestExecutionResult result)
- Parameters:
testDescriptor- theTestDescriptorassociated with the event; nevernullresult- theTestExecutionResultfor 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 aPredicatefor events whose payload types match the suppliedpayloadTypeand whose payloads match the suppliedpayloadPredicate.- Parameters:
payloadType- the required payload typepayloadPredicate- aPredicateto 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- aPredicateto 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 theTestDescriptorassociated with thisEvent.- Returns:
- the
TestDescriptor; nevernull
-
getTimestamp
public Instant getTimestamp()
Get theInstantwhen thisEventoccurred.- Returns:
- the
Instantwhen thisEventoccurred; nevernull
-
getPayload
public Optional<Object> getPayload()
Get the payload, if available.- Returns:
- an
Optionalcontaining the payload; nevernullbut 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
Optionalcontaining the payload; nevernullbut 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)
-
-