iwein is correct; however, there are some situations (such as embedded systems) in which there is not enough memory and you do not want to use or cannot use immutability.
The workaround I found is to use a different layout for each call, and then check the list of poppies, each of which has one call.
List<Mock> mocks = new ArrayList<Mock>(); ...init list w/ mocks using for loop... List<Object[]> expectedArgs = new ArrayList<Object[]>(); ..init list w/ desired args... mocks.get(0).callMethod(1, 2); ...do that some more... for(int i = 0; i < mocks.size(); i++) { Object[] desiredArgs = expectedArgs.get(i); verify(mocks.get(i)).callMethod((int) desiredArgs[0], (int) desiredArgs[1]); }
It is not so pretty, but you do not need to make your classes immutable in this way.
source share