I’d like to use strict mocks, at least when developing for the first time some tests against old code, so any methods invoked on my mock will throw an exception if I didn’t specifically define expectations.
From what I’ve come to see, Mockito if I didn’t define any expectations will just return null, which will later on cause a NullPointerException in some other place.
Is it possible to do that? If yes, how?
What do you want it to do?
You can set it to RETURN_SMART_NULLS, which avoids the NPE and includes some useful info.
You could replace this with a custom implementation, for example, that throws an exception from its
answermethod: