JUnit 4.5 runner initializes mocks annotated with {@link Mock}, so that explicit usage of {@link MockitoAnnotations#initMocks(Object)} is not necessary. Mocks are initialized before each test method.
Runner is completely optional - there are other ways you can get @Mock working, for example by writing a base class.
Read more in javadoc for {@link MockitoAnnotations}
Example:
@RunWith(MockitoJUnit44Runner.class) public class ExampleTest { @Mock private List list; @Test public void shouldDoSomething() { list.add(100); } }
|
|