You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like Mockito is using null as a default value for properties in a interface even though they are non-nullable.
Reproduce:
interfaceDog {
val name:String
}
classDogCaller {
funcallDog(dog:Dog) = callSomeone(dog.name)
privatefuncallSomeone(name:String) ="Hey $name come here!"
}
classDogCallerTests {
privateval dogCaller =DogCaller()
@Test
fun`dog caller should call dog by its name`() {
val beagle:Dog= mock()
// This makes the test pass // whenever(beagle.name).thenReturn("Firulais")
dogCaller.callDog(beagle)
verify(beagle).name // This fails cause it detects dog.name : String = null !
}
}