Does mockk support suspend inline?
Asked Answered
I

1

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

Interne answered 25/6, 2019 at 11:49 Comment(1)
Did you find a way around it?Vulgar
M
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.

Maldon answered 25/6, 2019 at 14:23 Comment(1)
Exactly. So, if you really need to mock, you have to go down de source code and mock its internal methodsFernery

© 2022 - 2024 — McMap. All rights reserved.