Skip to content

Compose Extension doesn't execute inside a test #368

Open
@sarimmehdi

Description

@sarimmehdi
class ExampleInstrumentedTest {

    @JvmField
    @RegisterExtension
    @ExperimentalTestApi
    val extension = createComposeExtension()

    @OptIn(ExperimentalTestApi::class)
    @Test
    fun test() {
        extension.use {
            setContent {
                MainScreen()
            }

            onNodeWithTag(SCREEN_A_TEST_TAG).assertTextEquals("false")
            println("should be here")
        }
        println("but instead I am here")
    }
}

In the above, inside test(), the code inside extension.use never executes. I know that because I do not see the print statement I put inside the code block ("should be here"). However, I do see "but instead I am here" which means extension.use was never executed. I am not sure if I am doing something wrong. I am simply following the comment here: #234 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions