Hi. I’m having an issue with mockk/arrow. If my re...
# mockk
k
Hi. I’m having an issue with mockk/arrow. If my return type is a String, the test passes. If the return type is a value class, I get an error
Inconsistent number of parameters in the descriptor and Java reflection object: 3 != 2
. Common code between the tests are:
Copy code
data object MyError1
data object MyError2

@JvmInline
value class TestId(val id: String)
Failing code:
Copy code
class Foo {
  context(Raise<MyError2>)
  suspend fun foo(): TestId {
    return TestId("hello")
  }
}

class Service(private val foo: Foo) {
  context(Raise<MyError1>)
  suspend fun test(): TestId {
    return withError({ MyError1 }) {
      foo.foo()
    }
  }
}

test("test 1") {
      val foo = mockk<Foo>()
      val service = Service(foo)

      coEvery {
        with(any<Raise<Any>>()) {
          foo.foo()
        }
      }.coAnswers { TestId("hello") }

      either {
        service.test()
      }.shouldBeRight()
    }
Passing code (where instead of having a
TestId
return type, I have a
String
return type.
Copy code
class Foo {
  context(Raise<MyError2>)
  suspend fun foo(): String {
    return "hello" 
  }
}

class Service(private val foo: Foo) {
  context(Raise<MyError1>)
  suspend fun test(): String {
    return withError({ MyError1 }) {
      foo.foo()
    }
  }
}

    test("test 1") {
      val foo = mockk<Foo>()
      val service = Service(foo)

      coEvery {
        with(any<Raise<Any>>()) {
          foo.foo()
        }
      }.coAnswers { "hello" }

      either {
        service.test()
      }.shouldBeRight()
    }