Mocked suspend function returns null in Mockito

后端 未结 2 1506
别跟我提以往
别跟我提以往 2021-01-04 14:58

I have a suspending functions that I have mocked, using Mockito but it is returning null

both projects use

\'org.jetbrains.kotlinx:kotlinx-coroutines         


        
2条回答
  •  旧巷少年郎
    2021-01-04 15:20

    Mockito has a special support for suspend functions, but in Kotlin 1.3 there were some changes in how coroutines are implemented internally, so older versions of Mockito are no longer recognize suspend methods compiled by Kotlin 1.3. And kotlinx.coroutines use Kotlin 1.3 since version 1.0.0.

    Corresponding support was added to Mockito, but only since version 2.23, so updating your Mockito version will help.

提交回复
热议问题