March 2018
Intermediate to advanced
324 pages
8h 30m
English
Mockito is a Java framework that allows easy creation of the test double.
The Gradle dependency is the following:
dependencies {
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.+'
}
Mockito runs through the JUnit runner. It creates all the required mocks for us and injects them into the class with tests. There are two basic approaches; instantiating mocks by ourselves and injecting them as class dependencies via a class constructor or using a set of annotations. In the next example, we are going to see how it is done using annotations.
In order for a class to use Mockito annotations, it needs to be run with MockitoJUnitRunner. Using the runner simplifies the process because you just simply add annotations to objects ...
Read now
Unlock full access