-
-
Notifications
You must be signed in to change notification settings - Fork 380
Closed
Description
This works in 1.13.14 but using 1.13.16 any function that returns a kotlin.Result
mocked using coEvery
fails with an exception that class kotlin.Result cannot be cast
.
Below is a sample where it happens. If I run the test here I get the following error:
class kotlin.Result cannot be cast to class java.lang.String
This same test passes with 1.13.14
interface InterfaceA {
suspend fun doSomething(): Result<String>
}
interface InterfaceB {
suspend fun onSuccess()
suspend fun onFailure()
}
class ClassA(
private val interfaceA: InterfaceA,
private val interfaceB: InterfaceB
) {
suspend fun testFunc() {
interfaceA.doSomething()
.onSuccess { interfaceB.onSuccess() }
.onFailure { interfaceB.onFailure() }
}
}
@Test
fun `test result`() = runTest {
val interfaceA = mockk<InterfaceA>()
val interfaceB = mockk<InterfaceB>()
coEvery { interfaceA.doSomething() } returns Result.success("hello")
coEvery { interfaceB.onSuccess() } just runs
coEvery { interfaceB.onFailure() } just runs
val classA = ClassA(
interfaceA = interfaceA,
interfaceB = interfaceB
)
classA.testFunc()
coVerify { interfaceB.onSuccess() }
}
nicolasguillen-tamedia
Metadata
Metadata
Assignees
Labels
No labels