Open jordigarcl opened 4 years ago
Your reproducer passes when I try it out. Maybe try checking your imports.
Also returning null
is the expected behaviour when a method hasn't been stubbed (depending on the type) - more info here.
Sorry, now I see I got this error cause inside callDog()
I passed dog.name
to another function which expected a non-nullable type. That's where the nullability of String
check failed.
Though from thecastNull()
in the file you referenced I see this is a totally intentional behaviour. Should it be the case though? String
has always been a "special" type. I expected the mock to return a '"nice" value such as ""
.
It would make sense to handle it that way. Would actually solve the issue seen in #241 without using the proposed workaround I believe. String
s have always been kind of problematic in regards to Mockito-kotlin.
It looks like Mockito is using
null
as a default value for properties in a interface even though they are non-nullable.Reproduce: