Robolectric with ActiveAndroid setup nullpointerexception on ActiveAndroid$ReflectionUtils

后端 未结 1 442
野的像风
野的像风 2021-01-21 20:26

I am trying to implement robolectric testing in an existing app. I can run simple static tests but when I add testing with ActiveAndroid I get NullPointerExceptions, I think Act

1条回答
  •  有刺的猬
    2021-01-21 21:25

    Ah, we had a similar issue. We resolved it by next Robolectric feature http://robolectric.org/custom-test-runner/

    We moved created method:

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        installMultiDex();
    }
    
    protected void installMultiDex() {
        MultiDex.install(this);
    }
    

    And overrided it in the test application:

    @Override
    protected void installMultiDex() {
        //don't do anything
    }
    

    0 讨论(0)
提交回复
热议问题