Espresso intent test failing

前端 未结 4 820
日久生厌
日久生厌 2021-02-01 15:46

I\'m learning android instrumentation testing with espresso. I have an app which has a drawer menu and there is a menu called About. I was testing click on that menu item and co

4条回答
  •  长情又很酷
    2021-02-01 16:12

    I had the same problem and solved it by using IntentsTestRule instead of ActivityTestRule. IntentsTestRule is a subclass of ActivityTestRule. Set up your @Rule which creates the activity like so:

    @Rule
    public IntentsTestRule mActivity = new IntentsTestRule(MyActivity.class) {
        @Override
        protected Intent getActivityIntent() {
            ...
        }
    };
    

    See the following project for more information: https://github.com/googlesamples/android-testing/tree/master/ui/espresso/IntentsBasicSample

提交回复
热议问题