title: Mockito not mocking private variables using @Spy
body: <p>I am attempting to mock a private instance variable <code>listOfStrings</code> using Mockito's <code>@Spy</code> annotation.</p>
  
  <pre><code>@RunWith(MockitoJUnitRunner.class)
  public class MyObjectTest {
  
    @InjectMocks
    MyObject myObject;
    @Spy
    List&lt;String&gt; listOfStrings;
  
    @Before
    public void before() {
      myObject = new MyObject();
    }
  
    @Test
    public void testCallListOfStrings() {
      Mockito.doReturn(new ArrayList().stream()).when(listOfStrings).stream();
      myObject.callListOfStrings();
    }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class MyObject {
  
    private List&lt;String&gt; listOfStrings;
  
    public void callListOfStrings() {
      listOfStrings.stream().forEach(System.out::println);
    }
  }
  </code></pre>
  
  <p>It does not appear to be mocking the instance variable, throwing a <code>NullPointerException</code>, obviously. </p>