Espresso test fails with NoActivityResumedException often

后端 未结 6 2198
既然无缘
既然无缘 2021-02-06 21:58

EDIT: Updated description and error message and added some images. Still have this problem.

I have a strange error that occur many times when running espresso tests. Af

6条回答
  •  不要未来只要你来
    2021-02-06 22:34

    You can wake up your device before every test using Uiautomator.

    @Before
    public void init(){
         UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
         Point[] coordinates = new Point[4];
         coordinates[0] = new Point(248, 1520);
         coordinates[1] = new Point(248, 929);
         coordinates[2] = new Point(796, 1520);
         coordinates[3] = new Point(796, 929);
         try {
             if (!uiDevice.isScreenOn()) {
                 uiDevice.wakeUp();
                 uiDevice.swipe(coordinates, 10);
             }
         } catch (RemoteException e) {
             e.printStackTrace();
         }
    }
    

提交回复
热议问题