所以我有以下代码:
When("SMS with location update command is received") {
every {
context.getString(R.string.location_sms,any(),any())
} returns "loc"
mainServiceViewModel.handleSms(SmsMessage("123","location"))
Then("SMS with location is sent to specified phone number") {
verify(exactly = 1) {
smsRepository.sendSms("+123","loc")
}
}
}
When("motion is detected") {
Then("information SMS is sent to specified phone number") {
verify(exactly = 1) {
smsRepository.sendSms("+123",any())
}
}
}
问题在于,即使第二种情况都不采取任何措施,两种情况都通过了。我希望第二种情况失败,因为甚至没有调用sendSms方法。
- 如何重置smsRepository验证计数?
- 如何在每次“何时”案例之前重置该计数?