-
I'm trying to figure out a way to test handling of a PopResult returned to an Answering Navigator in my presenter. From what I can tell the Sample logic: class Presenter(val navigator: Navigator) :CircuitUiPresenter {
fun present(): State {
val answeringNavigator = rememberAnsweringNavigator<OtherScreen.Result>(navigator) {
// logic to be tested
}
return State(
launchOtherScreen = {
answerNavigator.goTo(OtherScreen)
}
)
}
}
@Test
fun presenterTest = runTest {
val navigator = FakeNavigator()
Presenter(navigator).test {
awaitItem().launchOtherScreen()
// how do I trigger a OtherScreen.Result to test the result handling logic?
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Think this gets really close to being an integration test as it's verifying the interaction between the two screens? Should be able to setup a test using presenterTestOf({
withCompositionLocalProvider(LocalBackStack provides backstack) { presenter.present() }
}) { |
Beta Was this translation helpful? Give feedback.
Added a sample compose test for this with #1582.
It's testing the presenter in a headless fashion by capturing the states. Allows for interacting with the presenter across the navigation boundary in an integrated fashion.