假设我们有一个这样的类:
class Whatever {
private var something = false
fun aMethod(): Int {
return if( something ) {
1
} else {
0
}
}
}
根据文档,看起来我应该能够执行以下操作:
val classUnderTest = spyk(Whatever())
every { classUnderTest getProperty "something" } returns true
assertThat(classUnderTest.aMethod()).isEqualTo(1)
但是我得到了错误:io.mockk.MockKException: Missing calls inside every { ... } block
我正在使用 mockk 1.8.5,kotlin 1.2.51