7

It looks like coEvery hangs when I am trying to mock suspend inline function.

The code below works if remove inline modifier

Function in storeApi: suspend inline fun getAllStores(): List<Store>

Test code: coEvery { storeApi.getAllStores() } returns allStores

I'd like to have a way to mock suspend inline function, not only suspend

1

1 Answer 1

10

Simple answer - no, and not possible:

As other mocking frameworks, mockk relies on bytecode level instrumentation for methods. When you mark a function as inline the compiler will not generate a method on bytecode level though.

1
  • Exactly. So, if you really need to mock, you have to go down de source code and mock its internal methods Commented May 23 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.