title: Activity Unit testing using ActivityUnitTestCase
body: <p>I am trying to write Unit tests for activity methods using ActivityUnitTestCase. But always i am getting null pointer exception while calling <code>startActivity()</code>. Below is my code.</p>
  
  <p>I debugged and found this always returning null <code>getInstrumentation().getTargetContext()</code>. But i don't really understand whats happening here.</p>
  
  <p><strong>CODE</strong></p>
  
  <pre><code>public class ScoreBoardActivityTest extends ActivityUnitTestCase&lt;ScoreBoardActivity&gt; {
  
  public ScoreBoardActivity activity;
  
  
  public ScoreBoardActivityTest() {
      super(ScoreBoardActivity.class);
  }
  
  @Override
  protected void setUp() throws Exception {
      super.setUp();
      startActivity(new Intent(getInstrumentation().getTargetContext(), ScoreBoardActivity.class), null, null);
      activity = getActivity();
  }
  
  @Test
  public void testActivityNotNull(){
      Assert.assertNull(activity);
  }
  
  @Test
  public void testBatsmanOneAddRunButtonClickUpdateTotalRuns(){
      activity.onBatsmanOneAddRunClick(null);
      Assert.assertEquals(activity.totalRuns, 1);
  }
  }
  </code></pre>
  
  <p>What i am doing wrong here?</p>
  
  <p>Is there anything else i need to set it up?</p>