Skip to content

Why is no value being produced when I transform an observable into a flow and launch it in viewModelScope within the init block? #232

Closed Answered by jingibus
hvsimon asked this question in Q&A
Discussion options

You must be logged in to vote

Well, you aren't using Turbine wrong or anything. You are using Turbine correctly, but your test setup is failing to plug up Observable.just(2). By the time this line has run,

every { myRepository.getData() } returns Observable.just(2)

...myRepository.getData() has already run.

So: not really a question about Turbine, but more a question about "How do I do test setup with coroutines?"

Launching work in init is pretty common. If the subject is constructed inside a @Before, however, then it's not possible to configure any dependencies used by that work: by the time you get to @Test, the dependencies have already been invoked. So I prefer to avoid using @Before methods to construct the subj…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@hvsimon
Comment options

@jingibus
Comment options

Answer selected by hvsimon
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