使用 espresso 的 testUI (Jenkins)

2024-04-10

该应用程序正在本地通过 espresso 测试,我的意思是直接到设备和 genymotion 模拟器。当我使用 Jenkins 构建应用程序的映像时。浓缩咖啡测试未成功,我收到此错误。

JENKINS:

 java.lang.RuntimeException: Waited for the root of the view hierarchy to have window focus and not be requesting layout for over 10 seconds. If you specified a non default root matcher, it may be picking a root that never takes focus. Otherwise, something is seriously wrong. Selected Root:
Root{application-window-token=android.view.ViewRootImpl$W@536a97d4, window-token=android.view.ViewRootImpl$W@536a97d4, has-window-focus=false, layout-params-type=1, layout-params-string=WM.LayoutParams{(0,0)(fillxfill) sim=#100 ty=1 fl=#1810100 pfl=0x8 wanim=0x103028f}, decor-view-string=DecorView{id=-1, visibility=VISIBLE, width=800, height=1184, has-focus=true, has-focusable=true, has-window-focus=false, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}}
. All Roots:
Root{application-window-token=android.view.ViewRootImpl$W@536a97d4, window-token=android.view.ViewRootImpl$W@536a97d4, has-window-focus=false, layout-params-type=1, layout-params-string=WM.LayoutParams{(0,0)(fillxfill) sim=#100 ty=1 fl=#1810100 pfl=0x8 wanim=0x103028f}, decor-view-string=DecorView{id=-1, visibility=VISIBLE, width=800, height=1184, has-focus=true, has-focusable=true, has-window-focus=false, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}}
at com.google.android.apps.common.testing.ui.espresso.base.RootViewPicker.get(RootViewPicker.java:84)
at com.google.android.apps.common.testing.ui.espresso.ViewInteractionModule.provideRootView(ViewInteractionModule.java:51)
at com.google.android.apps.common.testing.ui.espresso.ViewInteractionModule$$ModuleAdapter$ProvideRootViewProvidesAdapter.get(ViewInteractionModule$$ModuleAdapter.java:187)
at com.google.android.apps.common.testing.ui.espresso.ViewInteractionModule$$ModuleAdapter$ProvideRootViewProvidesAdapter.get(ViewInteractionModule$$ModuleAdapter.java:151)
at com.google.android.apps.common.testing.ui.espresso.base.ViewFinderImpl.getView(ViewFinderImpl.java:52)
at com.google.android.apps.common.testing.ui.espresso.ViewInteraction$2.run(ViewInteraction.java:141)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

Stacktrace 意味着 Espresso 找不到应用程序窗口。在模拟器屏幕上进行测试时,屏幕通常隐藏在屏幕锁定后面。您需要使用一些代码以编程方式禁用屏幕锁定。 对我来说解锁屏幕最方便的方法是使用 Robotium。它有solo.unlockScreen()方法。我已将其放入测试生命周期的 setUp() 方法中。

Links: https://github.com/RobotiumTech/robotium/blob/master/robotium-solo/src/main/java/com/robotium/solo/Solo.java https://github.com/RobotiumTech/robotium/blob/master/robotium-solo/src/main/java/com/robotium/solo/Solo.java

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 espresso 的 testUI (Jenkins) 的相关文章

随机推荐