org.mockito.runners
public class MockitoJUnitRunner extends org.junit.runner.Runner implements org.junit.runner.manipulation.Filterable
UnnecessaryStubbingException.
To opt-out from this feature, use @RunWith(MockitoJUnitRunner.Silent.class)
Mock,
so that explicit usage of MockitoAnnotations.initMocks(Object) is not necessary.
Mocks are initialized before each test method.
Mockito.validateMockitoUsage().
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);
}
}
| Modifier and Type | Class and Description |
|---|---|
static class |
MockitoJUnitRunner.Silent
This Mockito JUnit Runner implementation ignores unused stubs
(e.g.
|
static class |
MockitoJUnitRunner.Strict
Detects unused stubs and reports them as failures.
|
| Constructor and Description |
|---|
MockitoJUnitRunner(Class<?> klass) |
| Modifier and Type | Method and Description |
|---|---|
void |
filter(org.junit.runner.manipulation.Filter filter) |
org.junit.runner.Description |
getDescription() |
void |
run(org.junit.runner.notification.RunNotifier notifier) |
public MockitoJUnitRunner(Class<?> klass) throws InvocationTargetException
InvocationTargetExceptionpublic void run(org.junit.runner.notification.RunNotifier notifier)
run in class org.junit.runner.Runnerpublic org.junit.runner.Description getDescription()
getDescription in interface org.junit.runner.DescribablegetDescription in class org.junit.runner.Runnerpublic void filter(org.junit.runner.manipulation.Filter filter)
throws org.junit.runner.manipulation.NoTestsRemainException
filter in interface org.junit.runner.manipulation.Filterableorg.junit.runner.manipulation.NoTestsRemainException