inlinesuspendmockk

Does mockk support suspend inline?


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


Solution

  • 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.