Class Event
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 EventdynamicTestRegistered(TestDescriptor testDescriptor) Create anEventfor the dynamic registration of the suppliedTestDescriptor.static EventexecutionFinished(TestDescriptor testDescriptor, TestExecutionResult result) static EventexecutionSkipped(TestDescriptor testDescriptor, @Nullable String reason) static EventexecutionStarted(TestDescriptor testDescriptor) Create a startedEventfor the suppliedTestDescriptor.static EventfileEntryPublished(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> TgetRequiredPayload(Class<T> payloadType) Get the payload of the required type.Get theTestDescriptorassociated with thisEvent.Get theInstantwhen thisEventoccurred.getType()Get the type of thisEvent.static EventreportingEntryPublished(TestDescriptor testDescriptor, ReportEntry entry) toString()
-
Method Details
-
reportingEntryPublished
- Parameters:
testDescriptor- theTestDescriptorassociated with the event; nevernullentry- theReportEntrythat was published; nevernull- Returns:
- the newly created
Event - See Also:
-
fileEntryPublished
@API(status=MAINTAINED, since="1.13.3") public static Event fileEntryPublished(TestDescriptor testDescriptor, FileEntry file) - Parameters:
testDescriptor- theTestDescriptorassociated with the event; nevernullfile- theFileEntrythat was published; nevernull- Returns:
- the newly created
Event - Since:
- 1.12
- See Also:
-
dynamicTestRegistered
Create anEventfor the dynamic registration of the suppliedTestDescriptor.- Parameters:
testDescriptor- theTestDescriptorassociated with the event; nevernull- Returns:
- the newly created
Event - See Also:
-
executionSkipped
- Parameters:
testDescriptor- theTestDescriptorassociated with the event; nevernullreason- the reason the execution was skipped; may benull- Returns:
- the newly created
Event - See Also:
-
executionStarted
Create a startedEventfor the suppliedTestDescriptor.- Parameters:
testDescriptor- theTestDescriptorassociated with the event; nevernull- Returns:
- the newly created
Event - See Also:
-
executionFinished
- Parameters:
testDescriptor- theTestDescriptorassociated with the event; nevernullresult- theTestExecutionResultfor 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 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
-
byTestDescriptor
public static Predicate<Event> byTestDescriptor(Predicate<? super TestDescriptor> testDescriptorPredicate) - Parameters:
testDescriptorPredicate- aPredicateto match against test descriptors- Returns:
- the resulting
Predicate
-
getType
Get the type of thisEvent.- Returns:
- the event type; never
null - See Also:
-
getTestDescriptor
Get theTestDescriptorassociated with thisEvent.- Returns:
- the
TestDescriptor; nevernull
-
getTimestamp
-
getPayload
-
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
Optionalcontaining the payload; nevernullbut 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
-