Abhimanyu
08/09/2025, 2:01 AMjava.lang.IllegalStateException: State must be at least 'CREATED' to be moved to 'DESTROYED' in component NavBackStackEntry(7a23a02c-5dfa-43df-8510-97bda229a7da) destination=Destination(0x98d0beb0) route=settings
Dependencies
navigation-compose = "2.9.0-beta03"
Abhimanyu
08/09/2025, 2:03 AM@RunWith(AndroidJUnit4::class)
internal class NavigationTest {
@get:Rule(order = 0)
val koinTestRule = KoinTestRule(
modules = listOf(
MyAppModule().module,
),
)
@get:Rule(order = 1)
val composeTestRule = createAndroidComposeRule<MainActivity>()
@Test
fun navigationTest() {
composeTestRule
.onNodeWithTag(
testTag = "screen_home",
)
.assertIsDisplayed()
composeTestRule.waitUntil {
composeTestRule
.onNodeWithContentDescription(
"Settings",
)
.isDisplayed()
}
// This click action is throwing the exception. It navigates to Settings screen on clicking.
composeTestRule
.onNodeWithContentDescription(
"Settings",
)
.performClick()
composeTestRule.waitForIdle()
}
}