我在单元测试中模拟了一个类。我想检查我的被测课程是否与之互动。但是,由于它位于withContext { } block
当我删除withContext代码时,测试将检测到交互并通过。但是,我需要用上下文将其包裹起来。
// I init the mocked object like so
val model: QRCodeModel = mock()
// I make sure I return some data when the mocked object is called
whenever(model.getQRCode()).thenReturn(bitmap)
// this is always failing when checking how many times it was interacted with
verify(model, times(1)).getQRCode()