title: Asserting that Mockito mocked object gets set to null
body: <p>I am using Mockito to do JUnit tests, and stuck figuring out an assertion issue. I'm creating a mock object, and then creating a presenter object using the mocked object.</p>
  
  <pre><code>@Mock
  Object mFooBar;
  
  private FooPresenter mFooPresenter;
  
  @Before
  public void setUp() throws Exception {
      MockitoAnnotations.initMocks(this);
  
      mFooPresenter = new FooPresenter(mFooBar);
  
  }
  </code></pre>
  
  <p>In the onDestroy() method in my presenter, I null out the object. </p>
  
  <pre><code>public FooPresenter(Object fooBar) {
      mFooBar = fooBar;
  }
  
  @Override
  public void onDestroy() {
      mFooBar = null;
  }
  </code></pre>
  
  <p>Then when I try to assertNull for mFooBar in my FooPresenterTest, it fails because it is not null.</p>
  
  <pre><code>@Test
  public void testThatObjectsAreNullifiedInOnDestroy() throws Exception {
      fooPresenter.onDestroy();
  
      assertNull(mFooBar);
  }
  </code></pre>
  
  <p>This fails as </p>
  
  <pre><code>Expected :&lt;null&gt;
  Actual :mFooBar
  </code></pre>
  
  <p>My questions then are, how are the references handled to the mocked objects in my test class compared to the object I instantiated to run the test? Why does assertNull fail when it should have been set to null?</p>