Skip to content

Test suspended MutableStateFlow consumer #89

Answered by JakeWharton
Kshitij09-sc asked this question in Q&A
Discussion options

You must be logged in to vote

If you are testing the visible flow then you can only test the values of the items which are emitted in reaction to events (presumably the thing which triggers the value to change).

You don't need to test that MutableStateFlow keeps the latest value / replays the latest value to collectors because you didn't write that class and you can trust it to behave as documented.

You can test the repeatOnLifecycle part of the codebase but only if you have some kind of indirection where you can intercept the values which it collects and you would not actually use Turbine for that because of the fact that it manages the collection of the flow. Instead you would set up a fake lifecycle, emit a value, …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Kshitij09-sc
Comment options

Answer selected by Kshitij09-sc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants