NullPointerException from LeakCanary when running Robolectric tests -


added leakcanary (1.3) application:

@override public void oncreate() {     super.oncreate();     fabric.with(this, new crashlytics());     leakcanary.install(this); 

when run robolectric test suite application nullpointerexception in leakcanary.

caused by: java.lang.nullpointerexception @ com.squareup.leakcanary.leakcanary.isinserviceprocess(leakcanary.java:165) @ com.squareup.leakcanary.leakcanary.isinanalyzerprocess(leakcanary.java:141) @ com.squareup.leakcanary.leakcanary.install(leakcanary.java:52) @ com.squareup.leakcanary.leakcanary.install(leakcanary.java:43) @ com.package.application.myapplication.oncreate(myapplication.java:50) @ org.robolectric.internal.paralleluniverse.setupapplicationstate(paralleluniverse.java:131) @ org.robolectric.robolectrictestrunner.setupapplicationstate(robolectrictestrunner.java:431) @ org.robolectric.robolectrictestrunner$2.evaluate(robolectrictestrunner.java:224) 

i added im using crashlytics point out (and other methods well) receives same application not throw exceptions.

wasn't sure if should here or on github issues leakcanary. else experiencing issue?

converting comment answer.

robolectric provides way deal different initialisations , application test lifecycles through test application.

here application class:

public class <yourappplication> extends application {     @override     public void oncreate() {         super.oncreate();         fabric.with(this, new crashlytics());         leakcanary.install(this);     } } 

you should put in test sources in same package yours application next class:

public class test<yourappplication> extends <yourapplication> {     @override     public void oncreate() {     } } 

robolectric load instead of application. can see suppress static initialisations application.

you can find more details here


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -