# FailureArtifact

Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/ComposeUiTestConfig.kt+class:androidx.compose.ui.test.FailureArtifact) Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.13.0-rc01) Common/AllAndroid/JVM
- Cmn

  ```
  class 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 `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/TestFailureHandler` receive a list of these artifacts within the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/FailureContext`.

The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/FailureArtifact#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 `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/FailureArtifact#fileName()` to retrieve the file's URI or read its bytes directly via the registry:

```kotlin
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 |
|---|
| `value class https://developer.android.com/reference/kotlin/androidx/compose/ui/test/FailureArtifact.Type` Defines the category of a `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/FailureArtifact`. |

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/FailureArtifact#FailureArtifact(androidx.compose.ui.test.FailureArtifact.Type,kotlin.String)(type: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/FailureArtifact.Type, fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/FailureArtifact#fileName()` The platform-specific name of the generated artifact file. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/FailureArtifact.Type` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/FailureArtifact#type()` The classification of the artifact, determining what kind of diagnostic data it contains (e.g., `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/FailureArtifact.Type#Screenshot()` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/FailureArtifact.Type#UiHierarchy()`). | Cmn |

## Public constructors

### FailureArtifact

Cmn Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.13.0-rc01)

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

## Public properties

### fileName

Cmn Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.13.0-rc01)

```
val fileName: String
```

The platform-specific name of the generated artifact file.

### type

Cmn

```
val type: FailureArtifact.Type
```

The classification of the artifact, determining what kind of diagnostic data it contains (e.g., `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/FailureArtifact.Type#Screenshot()` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/FailureArtifact.Type#UiHierarchy()`).