June 2014
Intermediate to advanced
284 pages
6h 9m
English
In this recipe, we will stub a void method that doesn't return a value, so it returns a custom answer.
For this recipe, our system under test will be the same class as the one in the previous recipe, but let's take another look at it so that you don't need to scroll around to see the source code. The PersonProcessor class does only one thing for simplicity: it delegates the process of saving person to the PersonSaver class. As shown in the following code, in case of success, true is returned; otherwise, false is returned:
public class PersonProcessor { private final PersonSaver personSaver; public PersonProcessor(PersonSaver personSaver) { this.personSaver = personSaver; } public ...Read now
Unlock full access