ThemedComposeRule

class ThemedComposeRule(theme: (content: () -> Unit) -> Unit, delegate: ComposeContentTestRule = createComposeRule()) : ComposeContentTestRule(source)

A compose rule that wraps every setContent in the app's theme, replacing per-test setContent { AppTheme { ... } } boilerplate.

@get:Rule val composeRule = ThemedComposeRule(theme = { content -> AppTheme(content = content) })

@Test fun showsTitle() {
composeRule.setContent { Title("Ready") }
composeRule.waitForText("Ready")
}

Parameters

theme

Wraps test content, for example in the app theme or a dark-mode variant.

delegate

The rule to wrap; defaults to createComposeRule().

Constructors

Link copied to clipboard
constructor(theme: (content: () -> Unit) -> Unit, delegate: ComposeContentTestRule = createComposeRule())

Functions

Link copied to clipboard
open override fun setContent(composable: () -> Unit)