I call a method performAction with list of objects and verify the same. After this method is called, I modify some of the "objects".
Mockito verify fails saying that arguments don't match (showing modified objects) but I can see in debug mode that objects were correct as needed.
Ideally, this should not happen as verify should be applied on the basis of when method was actually called. Does verify apply during verify call in test method than at the time of mocked method call?
Test Class
@Test
public void test() throws Exception {
List<ABC> objects = new ArrayList<ABC>();
//populate objects.
activity.performActions(objects);
verify(activity, times(1)).doActivity(objects);
}
Method to test:
public void performActions(List<ABC> objects) {
activity.doActivity(urlObjects2PerformAction);
//Modify objects
}
Error I am getting is as follows (this is for complete code. I have given smallest possible snippet):
Argument(s) are different! Wanted:
activity.doActivity(
.......
......