Anyone using JUnit tests along with ACRA?

53 views
Skip to first unread message

darrinps

unread,
Dec 11, 2012, 3:16:44 PM12/11/12
to acra-d...@googlegroups.com
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.

SKC

unread,
Mar 25, 2013, 7:47:20 AM3/25/13
to acra-d...@googlegroups.com
Something like this works:

public void onCreate() {
super.onCreate();
ACRAConfiguration config = ACRA.getNewDefaultConfig(this); 
ACRA.setConfig(config);
ACRA.init(this);
ACRA.getErrorReporter().setReportSender(new TestAcraReporter(this));
}

On Monday, March 25, 2013 4:19:27 PM UTC+5:30, Suvojit Chanda wrote:
Any updates on this issue, please let us know 
Reply all
Reply to author
Forward
0 new messages