gpt4 book ai didi

automated-tests - 找出 Espresso 究竟在哪一行失败

转载 作者:行者123 更新时间:2023-12-03 18:01:26 24 4
gpt4 key购买 nike

我正在我的 Android 应用程序上运行 Espresso 测试。如果一个失败,我将打印 View 树。不幸的是,我不知道这个故障究竟发生在哪一行。

有没有办法告诉 Espresso 在抛出异常时打印堆栈跟踪(例如 NoMatchingViewException),以便我可以看到我的测试在哪一行失败?

谢谢
托马斯

编辑:

我得到的输出看起来像(删除了中间的部分):

android.support.test.espresso.AmbiguousViewMatcherException: 'with id: com.wombatl.mobility.charge.test:id/stopChargingButton' matches multiple views in the hierarchy.
Problem views are marked with '****MATCHES****' below.
View Hierarchy:
+>DecorView{id=-1, visibility=VISIBLE, width=1080, height=2160, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=WM.LayoutParams{(0,0)(fillxfill) ty=1 fl=#81810100 pfl=0x20000 wanim=0x10302f6 needsMenuKey=2 colorMode=0}, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=3}
|
+->LinearLayout{id=-1, visibility=VISIBLE, width=1080, height=2034, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@48dbdb, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2}
|

(...)

|
+--------------->AppCompatTextView{id=2131361990, res-name=hoursTextView, visibility=VISIBLE, width=68, height=53, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.Rela

最佳答案

不,行号不会显示在失败消息中。你将不得不自己推断出来。

关于automated-tests - 找出 Espresso 究竟在哪一行失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54809218/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com