TestCaseStartedEvent


public final class TestCaseStartedEvent extends TestPlatformEvent


Represents the start of an individual test case. One TestCaseStartedEvent should always be emitted for each individual test case in a test run. However, there are a couple of test statuses that do not require an explicit TestCaseStartedEvent.

  • androidx.test.services.events.TestStatus.Status.IGNORED: The test was never started and will not be run.
  • androidx.test.services.events.TestStatus.Status.CANCELLED: The test was supposed to run, but this client encountered a state that required it to exit before the test could run.
See also
TestCaseFinishedEvent

to indicate the end of a test case

TestCaseErrorEvent

for reporting various errors encountered during a test run.

Summary

Public fields

final @NonNull TestCaseInfo

The test case that started.

final @NonNull TimeStamp

The time this test case started.

Public constructors

Creates a TestCaseStartedEvent from an Parcel.

TestCaseStartedEvent(
    @NonNull TestCaseInfo testCase,
    @NonNull TimeStamp timeStamp
)

Creates a TestCaseStartedEvent.

Public methods

TestPlatformEvent.EventType

The ITestPlatformEvent#send(TestPlatformEvent) service method receives an instance of the TestPlatformEvent base class, so the CREATOR factory in this class is being used to create the event instances, not the CREATOR of one of its derived instances.

void
writeToParcel(Parcel parcel, int i)

Public fields

testCase

public final @NonNull TestCaseInfo testCase

The test case that started.

timeStamp

public final @NonNull TimeStamp timeStamp

The time this test case started.

Public constructors

TestCaseStartedEvent

public TestCaseStartedEvent(Parcel source)

Creates a TestCaseStartedEvent from an Parcel.

Parameters
Parcel source

Parcel to create the TestCaseStartedEvent from.

TestCaseStartedEvent

public TestCaseStartedEvent(
    @NonNull TestCaseInfo testCase,
    @NonNull TimeStamp timeStamp
)

Creates a TestCaseStartedEvent.

Parameters
@NonNull TestCaseInfo testCase

the test case that started.

@NonNull TimeStamp timeStamp

the time the test case began.

Public methods

instanceType

public TestPlatformEvent.EventType instanceType()

The ITestPlatformEvent#send(TestPlatformEvent) service method receives an instance of the TestPlatformEvent base class, so the CREATOR factory in this class is being used to create the event instances, not the CREATOR of one of its derived instances.

Therefore the createFromParcel method first needs to read a String containing the EventType enum value of the correct derived type to instantiate. Derived classes should override this method to return the applicable event type.

Also note that this means only this base class provides a CREATOR, since the derived classes don't need one.

Returns
TestPlatformEvent.EventType

the EventType of the final derived event class that extends this base class

writeToParcel

public void writeToParcel(Parcel parcel, int i)