Espresso with Compose Empty Test Rule

Link to Espresso with Compose Empty Test Rule copied to clipboard
Free Trial

This example highlights the use of the setEmptyComposeTestRule(params) API available in axe DevTools Mobile with Compose. When utilizing the AxeDevToolsCompose object in UITests with the ComposeEmptyTestRule capabilities of Android, the setEmptyComposeTestRule(params) aids in setting the library up properly.

Quick links:

Below is an example of the AxeDevToolsCompose object in an Espresso test when utilizing the ComposeEmptyTestRule capabilities of Android.

Complete Example

class EmptyComposeRuleAPITest {
    val composeEmptyTestRule = createEmptyComposeRule()

    private lateinit var activity: ComponentActivity

    lateinit var scenario: ActivityScenario<ComponentActivity>

    companion object {
        val axe = AxeDevToolsCompose()

        init {

    fun setup() {
        scenario = ActivityScenario.launch(
        scenario.onActivity { activity ->
            this.activity = activity
            activity.setContent {
                Surface {
                    Column {
                        Text("Hello World")
        composeEmptyTestRule.mainClock.autoAdvance = false

    fun doGenericScan() {
        axe.setEmptyComposeTestRule(composeEmptyTestRule, activity)