June 2014
Intermediate to advanced
284 pages
6h 9m
English
In this recipe, we will verify that a specified method on a mock was executed and then any interactions stopped taking place.
For this recipe, our system under test will be a TaxTransferer class that will transfer tax for a non-null person. If the passed person value is null, then an error report is sent:
public class TaxTransferer {
private final TaxService taxService;
public TaxTransferer(TaxService taxService) {
this.taxService = taxService;
}
public void transferTaxFor(Person person) {
if (person == null) {
taxService.sendErrorReport();
return;
}
taxService.transferTaxFor(person);
}
}To verify that the only method executed on a mock is the one provided by us, you have ...
Read now
Unlock full access