Learning advanced Mockito features
Chapter 2, Socializing with Mockito, explained the external dependencies and provided examples of basic Mockito features, such as stubbing method calls, throwing exceptions, matching arguments, verifying method invocations, and answering method calls.
Mockito provides a fluent API for mocking Java objects. It offers a collection of advanced features for advanced users. This section deals with the advanced Mockito features and answers several questions, such as how to change the Mockito settings to return smart null values instead of default return types, how to reset a mock object to clear all previous information, how to determine whether an object is a spy or a mock, and how to capture arguments passed to a mock object and verify the values.
The following sections cover the advanced Mockito APIs.
Working with void methods
Unit testing void methods is difficult. Conventional unit tests prepare data, pass values to a method, and then assert the return type...