public abstract class

TestRunEvent

extends java.lang.Object

 java.lang.Object

↳androidx.test.services.events.run.TestRunEvent

Subclasses:

TestRunStartedEvent, TestFinishedEvent, TestStartedEvent, TestIgnoredEvent, TestFailureEvent, TestAssumptionFailureEvent, TestRunFinishedEvent, TestRunEventWithTestCase

Gradle dependencies

compile group: 'androidx.test', name: 'runner', version: '1.6.2'

  • groupId: androidx.test
  • artifactId: runner
  • version: 1.6.2

Artifact androidx.test:runner:1.6.2 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.test:runner com.android.support.test:runner

Overview

Base class for all other TestRunEvents to extend.

Summary

Fields
public static final <any>CREATOR

Methods
public intdescribeContents()

public voidwriteToParcel(Parcel parcel, int i)

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Fields

public static final <any> CREATOR

Methods

public int describeContents()

public void writeToParcel(Parcel parcel, int i)

Source

/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.test.services.events.run;

import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.RestrictTo;

/**
 * Base class for all other {@code TestRunEvents} to extend.
 *
 * @hide
 */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public abstract class TestRunEvent implements Parcelable {
  /** Creates a {@link TestRunEvent}. */
  TestRunEvent() {}

  /** Each derived class will return its corresponding EventType in {@link #instanceType()}. */
  enum EventType {
    STARTED,
    TEST_STARTED,
    TEST_FINISHED,
    TEST_ASSUMPTION_FAILURE,
    TEST_FAILURE,
    TEST_IGNORED,
    FINISHED
  }

  @Override
  public int describeContents() {
    return 0;
  }

  @Override
  public void writeToParcel(Parcel parcel, int i) {
    parcel.writeString(instanceType().name());
  }

  /**
   * The {@code ITestRunEvent#send(TestRunEvent)} service method receives an instance of the {@link
   * TestRunEvent} base class, so the {@link #CREATOR} factory in this class is being used to create
   * the event instances, not the {@code CREATOR} of one of its derived instances.
   *
   * <p>Therefore the {@code 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.
   *
   * <p>Also note that this means only this base class provides a {@code CREATOR}, since the derived
   * classes don't need one.
   *
   * @return the EventType of the final derived event class that extends this base class
   */
  abstract EventType instanceType();

  public static final Parcelable.Creator<TestRunEvent> CREATOR = new TestRunEventFactory();
}