I am trying to figure out a way to verify a class constructor in the following way (keep in mind this is a theoretical example)
public MyClass extends ItemContainer {
public MyClass(RoundItem a, SquareItem b) {
addItem(a);
addItem(b);
}
}
I would like to verify that the constructor called addItem once with any(RoundItem.class) and once with any(SquareItem.class). I can’t seem to find a good way to verify a constructor in such a way with PowerMock or Mockito. Any ideas?
You don’t really need a mocking framework in order to test this. You can make Test Spy object.
for example :