Package org.mockito.runners
Class MockitoJUnitRunner
- java.lang.Object
-
- org.junit.runner.Runner
-
- org.mockito.runners.MockitoJUnitRunner
-
- All Implemented Interfaces:
org.junit.runner.Describable
,org.junit.runner.manipulation.Filterable
- Direct Known Subclasses:
MockitoJUnit44Runner
public class MockitoJUnitRunner extends org.junit.runner.Runner implements org.junit.runner.manipulation.Filterable
Compatible with JUnit 4.4 and higher, this runner adds following behavior:-
Initializes mocks annotated with
Mock
, so that explicit usage ofMockitoAnnotations.initMocks(Object)
is not necessary. Mocks are initialized before each test method. -
validates framework usage after each test method. See javadoc for
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); } }
-
-
Constructor Summary
Constructors Constructor Description MockitoJUnitRunner(java.lang.Class<?> klass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
filter(org.junit.runner.manipulation.Filter filter)
org.junit.runner.Description
getDescription()
void
run(org.junit.runner.notification.RunNotifier notifier)
-
-
-
Method Detail
-
run
public void run(org.junit.runner.notification.RunNotifier notifier)
- Specified by:
run
in classorg.junit.runner.Runner
-
getDescription
public org.junit.runner.Description getDescription()
- Specified by:
getDescription
in interfaceorg.junit.runner.Describable
- Specified by:
getDescription
in classorg.junit.runner.Runner
-
filter
public void filter(org.junit.runner.manipulation.Filter filter) throws org.junit.runner.manipulation.NoTestsRemainException
- Specified by:
filter
in interfaceorg.junit.runner.manipulation.Filterable
- Throws:
org.junit.runner.manipulation.NoTestsRemainException
-
-