Compatible with
JUnit 4.4 and higher, this runner adds following behavior:
Runner is completely optional - there are other ways you can get @Mock working, for example by writing a base class.
Explicitly validating framework usage is also optional because it is triggered automatically by Mockito every time you use the framework.
See javadoc for
Mockito.validateMockitoUsage()
.
Read more about @Mock annotation in javadoc for MockitoAnnotations
@RunWith(MockitoJUnitRunner.class)
public class ExampleTest {
@Mock
private List list;
@Test
public void shouldDoSomething() {
list.add(100);
}
}