---
title: "FailureArtifact"
description: "Represents a diagnostic artifact produced by the test failure pipeline when a Compose UI test fails."
type: "class"
---
## API Reference

> Source set: Common

```kotlin
public class FailureArtifact(public val type: Type, public val fileName: String)
```

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](/jetpack-compose/androidx.compose.ui/ui-test/interfaces/TestFailureHandler/api) receive a list
of these artifacts within the [FailureContext](/jetpack-compose/androidx.compose.ui/ui-test/classes/FailureContext/api).

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:

## Members

### Type

> Source set: Common

```kotlin
public class Type private constructor(private val value: Int)
```

Defines the category of a [FailureArtifact](/jetpack-compose/androidx.compose.ui/ui-test/classes/FailureArtifact/api).

## Functions

### toString

> Source set: Common

```kotlin
override fun toString(): String
```

## Members

### Companion

> Source set: Common

```kotlin
public companion object
```

## Properties

### Screenshot

> Source set: Common

```kotlin
public val Screenshot: Type = Type(0)
```

### UiHierarchy

> Source set: Common

```kotlin
public val UiHierarchy: Type = Type(1)
```

## Code Examples

### failureArtifactStorageUsageSample

```kotlin
@Sampled
fun failureArtifactStorageUsageSample(artifact: FailureArtifact) {
    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)
}
```
