org.mockito.runners
Class MockitoJUnitRunner

java.lang.Object
  extended by org.junit.runner.Runner
      extended by 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:

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(MockitoJUnit44Runner.class)
 public class ExampleTest {
 
     @Mock
     private List list;
 
     @Test
     public void shouldDoSomething() {
         list.add(100);
     }
 }
 


Constructor Summary
MockitoJUnitRunner(java.lang.Class<?> klass)
           
 
Method Summary
 void filter(org.junit.runner.manipulation.Filter filter)
           
 org.junit.runner.Description getDescription()
           
 void run(org.junit.runner.notification.RunNotifier notifier)
           
 
Methods inherited from class org.junit.runner.Runner
testCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockitoJUnitRunner

public MockitoJUnitRunner(java.lang.Class<?> klass)
                   throws java.lang.reflect.InvocationTargetException
Throws:
java.lang.reflect.InvocationTargetException
Method Detail

run

public void run(org.junit.runner.notification.RunNotifier notifier)
Specified by:
run in class org.junit.runner.Runner

getDescription

public org.junit.runner.Description getDescription()
Specified by:
getDescription in interface org.junit.runner.Describable
Specified by:
getDescription in class org.junit.runner.Runner

filter

public void filter(org.junit.runner.manipulation.Filter filter)
            throws org.junit.runner.manipulation.NoTestsRemainException
Specified by:
filter in interface org.junit.runner.manipulation.Filterable
Throws:
org.junit.runner.manipulation.NoTestsRemainException