title: Using @Mock and @InjectMocks
body: <p>I'm currently studying the Mockito framework and I've created several test cases using Mockito.
  But then I read that instead of invoking mock(<em>SomeClass</em>.class) I can use the <code>@Mock</code> and the <code>@InjectMocks</code> - The only thing I need to do is to annotate my test class with <code>@RunWith(MockitoJUnitRunner.class)</code> or use the <code>MockitoAnnotations.initMocks(this);</code> in the <code>@Before</code> method.</p>
  
  <p>But it doesn't work - It seems that the <code>@Mock</code> won't work!
  Here is my 2 codes revisions - one using the annotations and one without.</p>
  
  <p>What am I doing wrong?</p>
  
  <pre><code>public class ReportServiceImplTestMockito {
  
      private TaskService       mockTaskService; // This is the Mock object
      private ReportServiceImpl service;
  
      @Before
      public void init(){
          service         = new ReportServiceImpl();
          mockTaskService = mock(TaskServiceImpl.class);
          service.setTaskServiceImpl(mockTaskService);
      }
  /// ...
  
   Some tests
  }
  </code></pre>
  
  <p>As I said - this work great.
  But the following wont:</p>
  
  <pre><code>@RunWith(MockitoJUnitRunner.class)
  public class ReportServiceImplTestMockito {
  
       @Mock 
       private TaskService      mockTaskService;
  
       @InjectMocks 
       private ReportServiceImpl service;
  
           // Some tests
  }
  </code></pre>
  
  <p>And here is the <code>ReportServiceImpl</code> class:</p>
  
  <pre><code>@Service
  public class ReportServiceImpl implements ReportService {
  
      @Autowired
      private TaskService taskServiceImpl;
  
      public ReportServiceImpl(){}
  
      public ReportServiceImpl(TaskService taskService){
          this.taskServiceImpl = taskService;
      }
  
      public void setTaskServiceImpl(TaskService taskServiceImpl) {
          this.taskServiceImpl = taskServiceImpl;
      }
  }
  </code></pre>
  
  <p>What am I missing?</p>