Testing with SugarORM and Robolectric

后端 未结 2 1971
醉酒成梦
醉酒成梦 2021-01-14 11:00

I trying to setup an testing environment for my android project. The basic Robolectric setup is done. I used this nice tutorial. If I comment out SugarORM in my Manifest.xml

2条回答
  •  攒了一身酷
    2021-01-14 11:42

    Ok try next. Add next class to you test code:

    public class TestSugarApp
        extends SugarApp
    {
        @Override
        public void onCreate() {}
    
        @Override
        public void onTerminate() {}
    }
    

    The class named Test will be loaded and used by Robolectric and you can override some things that are not relevant for testing. I'm trying to prevent to execute code from SugarApp in onCreate and onTerminate (https://github.com/satyan/sugar/blob/master/library/src/com/orm/SugarApp.java).

提交回复
热议问题