Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing 我可以在Kotlin中使用mock模拟通用(模板)私有方法吗?_Unit Testing_Kotlin_Mocking_Mockk - Fatal编程技术网

Unit testing 我可以在Kotlin中使用mock模拟通用(模板)私有方法吗?

Unit testing 我可以在Kotlin中使用mock模拟通用(模板)私有方法吗?,unit-testing,kotlin,mocking,mockk,Unit Testing,Kotlin,Mocking,Mockk,我想模拟以下函数: private fun updateItemInDb(id:Long,column:String,data:T) 我的类通过以下方式调用: updateItemInDb(it,DB_POS,i),其中it是一个Long,DB_POS是String,i是一个Int 我希望函数不做任何操作就运行。我在单元测试中尝试了以下操作: 1) 每个{adapter[“updateItemDB”](any(),any(),any())都会运行 这给了我一个类型不匹配错误:required M

我想模拟以下函数:

private fun updateItemInDb(id:Long,column:String,data:T)

我的类通过以下方式调用:

updateItemInDb(it,DB_POS,i)
,其中
it
是一个
Long
DB_POS
String
i
是一个
Int

我希望函数不做任何操作就运行。我在单元测试中尝试了以下操作:

1)
每个{adapter[“updateItemDB”](any(),any(),any())都会运行

这给了我一个类型不匹配错误:
required MockKStubScope,found MockKStubScope

2)
每个{adapter[“updateItemDB”](any(),any(),any())都回答{}


运行时此操作失败,io.mockk.mockkeException:现在找不到动态调用的函数updateItemInDb(-107815552064411229,-d008fa83c4f49c0,843241211)

是。通用私有函数已修复,因为我为其创建了一个问题。版本1.7.16应修复此问题。请检查并关闭GH问题,如果它正在工作。在你结束(如果是的话)之后,我会写一个关于这个问题的答案。