public final class

FailureInfo

extends java.lang.Object

 java.lang.Object

↳androidx.test.services.events.FailureInfo

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

Denotes an android test failure, has details of the failure including stack trace / type and message.

Summary

Fields
public static final <any>CREATOR

public final java.lang.StringfailureMessage

The failure message associated with the failure.

public final java.lang.StringfailureType

The type of failure exception.

public final java.lang.StringstackTrace

The stack trace associated with the failure.

public final TestCaseInfotestCase

The test case that caused the failure.

Constructors
publicFailureInfo(Parcel source)

Creates a FailureInfo from android .

publicFailureInfo(java.lang.String failureMessage, java.lang.String failureType, java.lang.String stackTrace, TestCaseInfo testCase)

Constructor to create a FailureInfo.

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 final java.lang.String failureMessage

The failure message associated with the failure.

public final java.lang.String failureType

The type of failure exception. E.g NullPointerException.

public final java.lang.String stackTrace

The stack trace associated with the failure.

public final TestCaseInfo testCase

The test case that caused the failure.

public static final <any> CREATOR

Constructors

public FailureInfo(java.lang.String failureMessage, java.lang.String failureType, java.lang.String stackTrace, TestCaseInfo testCase)

Constructor to create a FailureInfo.

public FailureInfo(Parcel source)

Creates a FailureInfo from android .

Parameters:

source: the android Parcel.

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;

import static androidx.test.internal.util.Checks.checkNotNull;

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

/**
 * Denotes an android test failure, has details of the failure including stack trace / type and
 * message.
 *
 * @hide
 */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public final class FailureInfo implements Parcelable {

  /** The failure message associated with the failure. */
  @Nullable public final String failureMessage;

  /** The type of failure exception. E.g {@code NullPointerException}. */
  @Nullable public final String failureType;

  /** The stack trace associated with the failure. */
  @NonNull public final String stackTrace;

  /** The test case that caused the failure. */
  @NonNull public final TestCaseInfo testCase;

  /** Constructor to create a {@link FailureInfo}. */
  public FailureInfo(
      @Nullable String failureMessage,
      @Nullable String failureType,
      @NonNull String stackTrace,
      @NonNull TestCaseInfo testCase) {
    checkNotNull(stackTrace, "stackTrace cannot be null");
    checkNotNull(testCase, "testCase cannot be null");
    this.failureMessage = failureMessage;
    this.failureType = failureType;
    this.stackTrace = stackTrace;
    this.testCase = testCase;
  }

  /**
   * Creates a {@link FailureInfo} from android {@link Parcel}.
   *
   * @param source the android Parcel.
   */
  public FailureInfo(@NonNull Parcel source) {
    checkNotNull(source, "source cannot be null");
    failureMessage = source.readString();
    failureType = source.readString();
    stackTrace = source.readString();
    testCase = source.readParcelable(TestCaseInfo.class.getClassLoader());
  }

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

  @Override
  public void writeToParcel(Parcel parcel, int i) {
    parcel.writeString(failureMessage);
    parcel.writeString(failureType);
    parcel.writeString(stackTrace);
    parcel.writeParcelable(testCase, i);
  }

  public static final Parcelable.Creator<FailureInfo> CREATOR =
      new Parcelable.Creator<FailureInfo>() {
        @Override
        public FailureInfo createFromParcel(Parcel source) {
          return new FailureInfo(source);
        }

        @Override
        public FailureInfo[] newArray(int size) {
          return new FailureInfo[size];
        }
      };
}