New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cancelAndIgnoreRemainingEvents()
does not cancel a Molecule StateFlow
#139
Comments
As far as Turbine is concerned, this is working as expected. The coroutine which is driving the You would see similar behavior with code like: val flow = neverFlow().stateIn(this, Unit)
flow.test { cancelAndIgnoreRemainingEvents() } If you launch any coroutines separately from Turbine they will also need to be canceled at the end of the test. You can do this by canceling all children of the |
In my pet project I overcame this by using |
Nice! Can you contribute something to the README about that pattern? |
About which pattern? Utilizing molecule + turbine to test composables? |
A bit more general in that the background scope can be used for launching things which produce a Although, in general, testing a So I'm not actually sure how detailed we want to get here. |
Gonna close the issue cause it's not really a bug. |
This might be Molecule-specific, but I still expect
cancelAndIgnoreRemainingEvents()
to be able to cancel anyStateFlow
.Here's a simple Molecule presenter:
And a test for it:
test()
never completes when executed, neither withcancelAndIgnoreRemainingEvents()
nor without it.The repro project is here: https://github.com/Egorand/turbine-cancel-hangs. Simply run
./gradlew app:testDebugUnitTest
to reproduce the issue.(Crappy) workaround:
The text was updated successfully, but these errors were encountered: