Java Testing

Updated: Sep 11, 2019 by Pradeep Gowda.

Unit tests with Mockito - Tutorial

Eliminate side effects by using test doubles.

Test Doubles:

Mockito Tutorial

@Mock injects the dependencies. @InjectMocks is the injectee class (typically the class being tested). The MockitoAnnotations.initMocks(this); inside the setup() is where these instances are created.

The when then pattern: