June 2014
Intermediate to advanced
284 pages
6h 9m
English
In this recipe, we will stub a void method. It doesn't return a value, so it returns a custom answer.
In this recipe, we'll reuse the example from the previous recipes. A quick reminder again – we have a system under test that consists of two objects: a PersonDataUpdator class that delegates work to TaxFactorService. The output of the system is a calculation of a mean value of tax factors (we have a fixed value for that). The person's data then gets updated via a web service. In this scenario, we will verify how our system works when an exception related to connectivity issues occurs. Have a look at the following code:
public class PersonDataUpdator { private final TaxFactorService ...