问题描述
我想实施一些 UI 测试以确保今天实施的代码明天适用,但在尝试查看过去实施的 UI 测试是否有效时,它抛出此错误:
Caused by: io.mockk.MockKException: Failed matching mocking signature for left matchers: [any(),any()]
这发生在 every {} return Unit
行上,其中有一个名为 WakeUpTimeManager 的对象文件,它调用 .set(param1,param2) 函数和 在该函数内部有一些内联函数,我认为这可能会导致问题,但我不知道。我尝试在互联网上搜索但找不到解决方案。
这是抛出错误的测试:
@Before
fun setup() {
mockkObject(WakeUpTimerManager)
every { WakeUpTimerManager.set(any(),any()) } returns Unit
}
这是在 every
行调用的函数
fun set(context: Context,timer: Timer) {
if (timer.atMillis < System.currentTimeMillis()) {
return
}
if (Preset.findByID(context,timer.presetID) == null) {
return
}
//This is an inline function
withGson {
PreferenceManager.getDefaultSharedPreferences(context).edit {
putString(PREF_WAKE_UP_TIMER,it.toJson(timer))
}
}
//This is an inline function
withAlarmManager(context) {
it.setAlarmClock(
AlarmManager.AlarmClockInfo(timer.atMillis,getPendingIntentForActivity(context)),getPendingIntentForService(context,timer)
)
}
}
问题: 为什么 mockk 会抛出这个错误?这是怎么回事?有什么解决办法吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)