Joan Colmenero
06/19/2019, 12:53 PMmockito
and suspend fun
? I remember when I did unit testing with rxJava
I had to create a Rule
and things like that, do I have to do something special to make it work?
Note: I'm using MVP not MVVM I don't know if it's a good pointtseisel
06/19/2019, 1:21 PMJoan Colmenero
06/19/2019, 1:58 PMtseisel
06/19/2019, 2:29 PM@Mock
annotation with MockitoRule
),
- stub a suspending method of that mock, so that it returns an expected result (given(...).willReturn(...)
),
- verify that a suspend method of that mock has been called (verify(...)
).Joan Colmenero
06/19/2019, 3:03 PMprivate val dispatcher = TestCoroutineDispatcher()
tseisel
06/19/2019, 4:20 PMrunBlockingTest
. All of those are available in kotlinx-coroutines-test
: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-test/