Peter Farlow
12/22/2022, 3:18 PMTestScope.backgroundScope
. Perhaps this example is more correct:
class ExampleClassTest {
private val mockApi = mockk<LoginApi> { coEvery { performLogin() } returns "hello" }
private val testCoroutineScheduler = UnconfinedTestDispatcher()
private val testScope = TestScope(testCoroutineScheduler)
@Test
fun `this test passes`() = testScope.runTest {
val exampleClass = ExampleClass(mockApi, testScope.backgroundScope)
expect("hello") {
exampleClass.performLogin()
}
}
}
Peter Farlow
12/27/2022, 8:00 PM