How can one test a function that does not return a value, but uses given arguments to construct some values which are being sent to a sequential function?
For example
public void handleSomeEvent(String str1, String str2){
MyObject obj1 = new MyObject();
obj1.setParameterA(str1);
obj2.setParameterB(str2);
EventHandler.getInstance().notify(obj1)
}
In the above example i would like to verify EventHandler.notify
was called with an object containing str1
as parameterA
and str2
as parameter2
. Can this be done using some common mocking frameowrk (i.e mockito)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…