title: Nullpointerexception when get button background in android testcase
body: <p>In my app, I want to test button background is correct with what I expect. But I get Nullpointerexception error when try to get button background. I can not see where I wrong.
  My code below:</p>
  
  <pre><code>    Button btnGetStarted = (Button) getActivity().findViewById(R.id.btnGetStarted);
      Drawable actual = btnGetStarted.getBackground();
      Drawable expect = getActivity().getResources().getDrawable(R.drawable.btn_active_normal);
      assertTrue("Wrong button background", actual==expect);
  </code></pre>
  
  <p>Nullpointerexception at line `Drawable actual = btnGetStarted.getBackground();</p>
  
  <p>I can not solve it after 2 days so I post it on here to looking for help.</p>
  
  <p>Edit:</p>
  
  <p>In xml file I set button background from a picture <code>btn_getstarted.png</code> like this: <code>android:background="@drawable/btn_getstarted"</code></p>