https://kotlinlang.org logo
#compose
Title
# compose
o

Odin

07/29/2021, 2:14 PM
Hi this might be a silly question, but is there something fancy you have to do to make testing in compose work? I have this test (see code in thread) but it looks like it just stalls and then after 45 sek it gives the error
Copy code
java.lang.AssertionError: Activity never becomes requested state "[RESUMED, CREATED, STARTED, DESTROYED]" (last lifecycle transition = "PRE_ON_CREATE")
I saw that someone here had this problem before and solved it by adding a ComponentActivity in their manifest, but I just get the same result. Has anyone here had the same experience? 😄 🤔
Copy code
@LargeTest
@HiltAndroidTest
class TriviaMenuUiTest {
    @get:Rule(order = 0)
    val hiltAndroidRule = HiltAndroidRule(this)

    @get:Rule(order = 1)
    val composeTestRule = createComposeRule()

    @Test
    fun testQuickPlayButtonIsPresent() {

        composeTestRule.setContent {
            KiwiTheme {
                TriviaMenu(
                    onQuickStart = { /*TODO*/ },
                    onBrowseCategories = { /*TODO*/ },
                    onBrowsePreviousResults = { /*TODO*/ },
                    signOut = { }
                )
            }
        }

        composeTestRule.apply {
            onNodeWithTag("quick-play")
                .assertExists("Quick play button does not exist")

            onNodeWithTag("quick-play")
                .assertIsDisplayed()
        }
    }
}
t

theapache64

03/08/2022, 4:58 PM
@Odin I think am having the same issue with gradle plugin
7.2.0-beta01
. Were you able to fix it?
o

Odin

03/09/2022, 7:40 AM
I unfortunately can't recall what the solution to this was, but I think it was due to some dependency incompatibilities
t

theapache64

03/13/2022, 9:13 AM
@Odin No problem. In my case, the culprit was jacoco dependency
136 Views