-
-
Notifications
You must be signed in to change notification settings - Fork 380
Open
Labels
Description
The following test case
@JvmInline
private value class StringValue(val value: String)
class NullableValueFromSuspendTest {
@Test
fun `verify mock returning nullable value class from suspend function`() {
class MockTarget {
suspend fun value(): StringValue? {
yield()
return null
}
}
val mock = mockk<MockTarget> {
coEvery { value() } returns StringValue("hello")
}
val result = runBlocking { mock.value() }
assertEquals("hello", result?.value)
}
}
results in the following failure:
class io.mockk.core.StringValue cannot be cast to class java.lang.String (io.mockk.core.StringValue is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
java.lang.ClassCastException: class io.mockk.core.StringValue cannot be cast to class java.lang.String (io.mockk.core.StringValue is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
at io.mockk.core.NullableValueFromSuspendTest$verify mock returning nullable value class from suspend function$result$1.invokeSuspend(NullableValueFromSuspendTest.kt:27)
...
This test passes against 1.13.14 and was likely introduced in #1332.
crysis74, SimonMarquis, akoufa, DexterBishop and nicolasguillen-tamedia