June 2014
Intermediate to advanced
284 pages
6h 9m
English
In this recipe, we will verify whether a method on a mock was executed for exactly the given number of times.
For this recipe, our system under test will be TaxUpdater, which calls TaxService (let's assume that it is a web-service client) to update the mean tax factor for two people. Unfortunately, this system is old and can accept a single call at a time. For simplicity, the calculateMeanTaxFactor() method, shown in the following code, returns a fixed value but in reality, there could be some complex logic:
public class TaxUpdater { static final double MEAN_TAX_FACTOR = 10.5; private final TaxService taxService; public TaxUpdater(TaxService taxService) { this.taxService = taxService; ...Read now
Unlock full access