I am new to unit testing in java so please excuse if this is a silly question. I have a method like the one below. What I want to do is verify that this method is being called and also check that the parameters that are passed are not null and also being called. How can I go about doing this in junit/mockito?
public <return type> callMe(Object objectA) { if(objectA.name != null && objectA.age != null) { someOtherMethod(objectA.name, objectA.age) } }
someOtherMethodproduce any effect that can be observed from outside the class under test? If yes - then you should be asserting on that publicly visible effect, rather than the fact thatsomeOtherMethodwas called, which is an implementation detail.CallMe callMe = new CallMeand then do something likecallMe.someOtherMethod?