0
我得到的错误是org.mockito.exceptions.misusing.UnfinishedStubbingException
,其中一个可能的原因是“如果完成之前你在另一个模拟内部存储行为”。模拟创作内Mockito模拟创建
val mockHttpHandlerContext = mock<HttpHandlerContext>().let {
whenever(it.request).thenReturn(mock<HttpRequest>().let {
whenever(it.queryParameters).thenReturn(mapOf(
"itype" to listOf("msisdn"),
"uid" to listOf(inputMsisdn)
))
it
})
whenever(it.scope()).thenReturn(ProcessingScope.of(Timings("test", 1000L)))
it
}
是摆脱嵌套模拟创造的唯一解决方案?这真的会让代码更难理解,也许有一个已知的解决方法?
代码片段是Kotlin。