I'm having an issue getting Android JUnit tests to run with ACRA. When I try to run them, it dies with a null pointer. This app works fine if run as a normal application, just not when as a JUnit test.
I put some debug statements in to help me see what is going on. It looks like the helper method inside the MyCrashReporter that is used to get the application context is getting called before the onCreate(). This only happens that way in the test runner...not in normal app running where onCreate() gets hit first.
My manifest for the test looks like this:
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="
com.mycompany.android" />
<application
android:name=".MyCrashReporter"
android:debuggable="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<uses-library android:name="android.test.runner" />
</application>
Any idea what it is that needs to be done to get this to work? Again, all is fine if run as an application as the onCreate() gets called first as it should. It's just when the JUnit test is run that this doesn't happen in the order expected.
Thanks.