When I run the test below (created only to illustrate a real problem) I expect it to pass, but it doesn't.
@JvmInline value class MyValueClass(
val value: String,
)
class MyClass {
fun myMethod(myValueClass: MyValueClass): String = myValueClass.value
}
class Test {
@Test
fun testDoSomething() {
val myValueClass = MyValueClass("something")
val mock = mock<MyClass>()
whenever(mock.myMethod(eq(myValueClass))).thenReturn("something")
assertThat(mock.myMethod(myValueClass)).isEqualTo("something")
}
}
However, if I refactor the MyValueClass to be a data class, it works. Any workaround to make it work?
When I run the test below (created only to illustrate a real problem) I expect it to pass, but it doesn't.
However, if I refactor the
MyValueClassto be adata class, it works. Any workaround to make it work?