TestFailurePolicy


Configuration for the failure handling pipeline in Compose UI tests.

A TestFailurePolicy dictates what diagnostic artifacts the testing framework should capture when a test fails (such as screenshots or UI tree dumps), and provides a mechanism to execute custom TestFailureHandlers to process those artifacts or report the failure.

By default, the capture modes are set to CaptureMode.Unspecified. This means the framework will fall back to the suite-level runner configuration (e.g., Instrumentation arguments on Android) to determine if artifacts should be generated. Setting a mode explicitly to CaptureMode.Enabled or CaptureMode.Disabled will override the suite-level configuration for the specific test using this policy.

Summary

Nested types

Represents a tri-state flag for failure artifact captures, allowing individual test configurations to explicitly override or fall back to suite-level runner arguments.

Public constructors

TestFailurePolicy(
    screenshotCaptureMode: TestFailurePolicy.CaptureMode,
    uiHierarchyCaptureMode: TestFailurePolicy.CaptureMode,
    failureHandlers: List<TestFailureHandler>
)
Cmn
android

Public functions

open operator Boolean
equals(other: Any?)
android
open Int
android

Public properties

List<TestFailureHandler>

A list of custom TestFailureHandlers that will be invoked in sequence after the framework completes its artifact generation.

Cmn
android
TestFailurePolicy.CaptureMode

Determines whether a visual screenshot of the screen/UI should be captured upon failure.

Cmn
android
TestFailurePolicy.CaptureMode

Determines whether a text-based dump of the UI and semantics trees should be captured upon failure.

Cmn
android

Public constructors

TestFailurePolicy

TestFailurePolicy(
    screenshotCaptureMode: TestFailurePolicy.CaptureMode = CaptureMode.Unspecified,
    uiHierarchyCaptureMode: TestFailurePolicy.CaptureMode = CaptureMode.Unspecified,
    failureHandlers: List<TestFailureHandler> = emptyList()
)

Public functions

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

Public properties

failureHandlers

val failureHandlersList<TestFailureHandler>

A list of custom TestFailureHandlers that will be invoked in sequence after the framework completes its artifact generation.

screenshotCaptureMode

val screenshotCaptureModeTestFailurePolicy.CaptureMode

Determines whether a visual screenshot of the screen/UI should be captured upon failure.

uiHierarchyCaptureMode

val uiHierarchyCaptureModeTestFailurePolicy.CaptureMode

Determines whether a text-based dump of the UI and semantics trees should be captured upon failure.