FailureArtifact


Represents a diagnostic artifact produced by the test failure pipeline when a Compose UI test fails.

Artifacts capture the state of the UI at the moment of failure, such as visual screenshots or structural UI hierarchy dumps. Custom handlers implementing TestFailureHandler receive a list of these artifacts within the FailureContext.

The fileName serves as an identifier to access the underlying file. The exact location and lifecycle of this file depend on the specific platform's test storage mechanisms.

Android Platform: On Android, the framework writes these artifacts to the PlatformTestStorage provided by AndroidX Test. You can use the fileName to retrieve the file's URI or read its bytes directly via the registry:

import androidx.test.platform.io.PlatformTestStorageRegistry

val storage = PlatformTestStorageRegistry.getInstance()

// Retrieve a Uri to share, delete, or process the file
val uri = storage.getOutputFileUri(artifact.fileName)

// Or open an input stream to read the generated file directly
val inputStream = storage.openInputFile(artifact.fileName)

Summary

Nested types

Defines the category of a FailureArtifact.

Public constructors

Cmn

Public properties

String

The platform-specific name of the generated artifact file.

Cmn
FailureArtifact.Type

The classification of the artifact, determining what kind of diagnostic data it contains (e.g., Type.Screenshot or Type.UiHierarchy).

Cmn

Public constructors

FailureArtifact

FailureArtifact(type: FailureArtifact.Type, fileName: String)

Public properties

fileName

val fileNameString

The platform-specific name of the generated artifact file.

type

val typeFailureArtifact.Type

The classification of the artifact, determining what kind of diagnostic data it contains (e.g., Type.Screenshot or Type.UiHierarchy).