It looks like Mockito is using null as a default value for properties in a interface even though they are non-nullable.
Reproduce:
interface Dog {
val name: String
}
class DogCaller {
fun callDog(dog: Dog) = callSomeone(dog.name)
private fun callSomeone(name: String) = "Hey $name come here!"
}
class DogCallerTests {
private val 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 !
}
}