title: junit.framework.AssertionFailedError: Exception in constructor: testMethod (java.lang.NullPointerException)
body: <p>I tried to test my Activity, but I ran into the problem: when I try to run Android JUnit project it fails on start with this stack trace:</p>
  
  <pre><code>junit.framework.AssertionFailedError: Exception in constructor: test (java.lang.NullPointerException
  at android.test.ActivityInstrumentationTestCase2.getActivity(ActivityInstrumentationTestCase2.java:100)
  at com.sogemobile.saytv.api.UploadAvatarTest2.&lt;init&gt;(UploadAvatarTest2.java:16)
  at java.lang.reflect.Constructor.constructNative(Native Method)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
  at junit.runner.BaseTestRunner.getTest(BaseTestRunner.java:118)
  at android.test.AndroidTestRunner.getTest(AndroidTestRunner.java:148)
  at android.test.AndroidTestRunner.setTestClassName(AndroidTestRunner.java:56)
  at android.test.suitebuilder.TestSuiteBuilder.addTestClassByName(TestSuiteBuilder.java:80)
  at android.test.InstrumentationTestRunner.parseTestClass(InstrumentationTestRunner.java:444)
  at android.test.InstrumentationTestRunner.parseTestClasses(InstrumentationTestRunner.java:425)
  at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:370)
  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4382)
  at android.app.ActivityThread.access$1300(ActivityThread.java:141)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1294)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:137)
  at android.app.ActivityThread.main(ActivityThread.java:5039)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
  at dalvik.system.NativeStart.main(Native Method)
  at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
  at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
  at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
  at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1661)
  </code></pre>
  
  <p>My test code is:</p>
  
  <pre><code> public class UploadAvatarTest2 extends ActivityInstrumentationTestCase2&lt;EmptyActivity_&gt; {
  
      public UploadAvatarTest2() {
           super(EmptyActivity_.class);
           getActivity();
      }
  
      public void test(){
      }
  
   }
  </code></pre>
  
  <p>I've found that the problem is "getActivity()" call. If I place breakpoint at "super(EmptyActivity_.class)" debugger won't even stop on that. But if I remove "getActivity()" string debugger will stop. It looks fantastic, but it's true :) I tried to restart eclipse/emulator but it doesn't affect anything.</p>
  
  <p>What should I do to solve the problem? :(</p>