June 2014
Intermediate to advanced
284 pages
6h 9m
English
In the following recipe, we will replace an existing bean with a test double using Spring's XML configuration.
Let's assume that our system under test is the tax transferring system for a given person, as shown in the following code:
public class TaxTransferer {
private final TaxService taxService;
public TaxTransferer(TaxService taxService) {
this.taxService = taxService;
}
public boolean transferTaxFor(Person person) {
if (person == null) {
return false;
}
taxService.transferTaxFor(person);
return true;
}
}As shown in the previous example, TaxService is a class that will perform a web service call. For readability purposes, we are simulating that we have such ...