I setup my content in composeTestRule in `@Before`...
# compose
a
I setup my content in composeTestRule in
@Before
Copy code
composeTestRule.setContent {
    MainNavHost()
}
How can I finish the activity completely in
@After
I tried
Copy code
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
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
Actually it sends the activity to background when the test finishes. But doesn't force close it.
So when the next test starts with
Copy code
composeTestRule.setContent {
    MainNavHost()
}
the activity is brought to front with the content which was there at the end of first test.