https://kotlinlang.org logo
Title
a

Arun Joseph

02/03/2022, 9:54 AM
I setup my content in composeTestRule in
@Before
composeTestRule.setContent {
    MainNavHost()
}
How can I finish the activity completely in
@After
I tried
composeTestRule.activity.finish()
But that hangs forever
I managed to use
Espresso.pressBack()
to restore the activity to its main screen. Probably I should be navigating using my NavHost within my tests?
m

mattinger

02/03/2022, 3:21 PM
Wouldn’t composeTestRule automatically close the activity for you?
Internally it’s using ActivityScenarioRule which calls close on the secnario in the after phase.
a

Arun Joseph

02/03/2022, 3:25 PM
Actually it sends the activity to background when the test finishes. But doesn't force close it.
So when the next test starts with
composeTestRule.setContent {
    MainNavHost()
}
the activity is brought to front with the content which was there at the end of first test.