June 2014
Intermediate to advanced
284 pages
6h 9m
English
In the previous recipe, you have seen how to pass an implementation of the Answer interface to your mock to change its default behavior. In this recipe, we will focus on doing the same when creating mocks using annotations.
All versions of Mockito up until version 1.9.5 allow you to pass only elements of the Answers enum that delegate to answers present in the public Mockito API, as the arguments of the annotation. In the next Mockito release, there should be a possibility of passing a custom answer too, but until then it's not possible to do that.
In the following code, our system is a class that, based on the person's country, collects his Internal Revenue Service (
Read now
Unlock full access