Mockito: How do I mock an instance creation?
consider that I need to mock the following line
employee.addOffer(employee, new Offer(details));
Now I need to mock the new Offer(details) to do nothing
The way I try is
doNothing().when(employee).addOffer(any(Employee.class), any(Offer.class));
This fails with NullPointerException because it tries to execute new
Offer(details) and details is nothing
How can I mock new Offer(details) to return any other mock?
No comments:
Post a Comment