如何从 Play 商店返回应用
How to go back to app from play store
我正在测试应用程序中的交互,用户可以向上滑动以转到 Google Play 商店。但是当发生这种情况时,Espresso 无法执行其余的测试流程,原因是 RuntimeException: Could not find RESUMED activity on main thread.
在 UI 上有向左箭头 (<--),因此用户可以点击它返回到上一个应用程序。我如何告诉 Espresso 做类似的事情?还是强制被测应用重新回到前台?
下面是RuntimeException供参考:
java.lang.RuntimeException: Could not find RESUMED activity on main thread
at com.snapchat.android.crema.Screenshotter.screenshotCurrentActivity(Screenshotter.java:49)
at com.snapchat.android.crema.Screenshotter.run(Screenshotter.java:33)
at android.app.Instrumentation$SyncRunnable.run(Instrumentation.java:2092)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
INSTRUMENTATION_RESULT: shortMsg=Process crashed.
INSTRUMENTATION_CODE: 0
Espresso 不能用于跨应用测试。 Espresso 与您的申请流程绑定。
但是有一些方法可以测试这种交互:
通过 Espresso-Intents 和 return 存根响应捕捉去 Play 商店的意图。这样,您的测试将被固定下来并且永远不会离开您的应用程序。这是一种推荐的做法,因为它会单独测试此场景,而不会与您无法控制的外部依赖项进行交互。
使用UiAutomator that can act outside of the context of your application and click things there. Might be useful if you are interested in end-end testing, but with the tradeoff of being more fragile. You can find sample usage in this question: How to regain Access on a Activity after sending it to background
我正在测试应用程序中的交互,用户可以向上滑动以转到 Google Play 商店。但是当发生这种情况时,Espresso 无法执行其余的测试流程,原因是 RuntimeException: Could not find RESUMED activity on main thread.
在 UI 上有向左箭头 (<--),因此用户可以点击它返回到上一个应用程序。我如何告诉 Espresso 做类似的事情?还是强制被测应用重新回到前台?
下面是RuntimeException供参考:
java.lang.RuntimeException: Could not find RESUMED activity on main thread
at com.snapchat.android.crema.Screenshotter.screenshotCurrentActivity(Screenshotter.java:49)
at com.snapchat.android.crema.Screenshotter.run(Screenshotter.java:33)
at android.app.Instrumentation$SyncRunnable.run(Instrumentation.java:2092)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
INSTRUMENTATION_RESULT: shortMsg=Process crashed.
INSTRUMENTATION_CODE: 0
Espresso 不能用于跨应用测试。 Espresso 与您的申请流程绑定。
但是有一些方法可以测试这种交互:
通过 Espresso-Intents 和 return 存根响应捕捉去 Play 商店的意图。这样,您的测试将被固定下来并且永远不会离开您的应用程序。这是一种推荐的做法,因为它会单独测试此场景,而不会与您无法控制的外部依赖项进行交互。
使用UiAutomator that can act outside of the context of your application and click things there. Might be useful if you are interested in end-end testing, but with the tradeoff of being more fragile. You can find sample usage in this question: How to regain Access on a Activity after sending it to background