I have an Object that may be null.
I want to verify that when an object is null, it's method is not invoked.
I wrote a test case that looks like this:
String str = mock(String.class);
str = null;
verify(str, never()).length();
But Mockito replies with:
org.mockito.exceptions.base.MockitoException:
Cannot mock/spy class java.lang.String
Mockito cannot mock/spy following:
- final classes
- anonymous classes
- primitive types
How do I verify that my a method is not invoked on a null Object?