Since SomeController.class
is itself a mock, u need to mock its methods responses. What u did was to mock a method someMethod()
inside the method createReturnType()
that is actually called. What will happen is that the method createReturnType()
in the mcoked class will be ignored of what is inside it returning null. A fixation to ur code is to either:
createReturnType()
itself to get a resultSomeController.class
instead of mocking itBut in either ways, its not a best practice to test mock the class of the methods that is needed to be tested since testing is calling the actual method testing its behaviour.