【发布时间】:2018-05-04 05:35:04
【问题描述】:
我是使用 espresso 来测试 android 应用程序的新手。 我试图测试图像。在网上搜索时,我得到了一个链接来获取代码来测试图像。
我已经在我的编码中实现了这一点。它适用于某些图像验证。但它不适用于其他一些图像。我不知道它为什么会这样。
对于上面的代码,我遇到了类似的错误,
android.support.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 'with drawable from resource id: <2131230851>' doesn't match the selected view.
Expected: with drawable from resource id: <2131230851>[o2]
Got: "AppCompatImageView{id=2131296484, res-name=imgSPO2, visibility=VISIBLE, width=150, height=91, 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, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=-1.0}"
特此附上链接,我可以在其中获取测试图像的代码。
任何人都可以帮助我克服这个问题。
我的测试代码是,
@Test
public void Test1_Spo2()
{
onView(withId(R.id.imgSPO2)).check(matches(withDrawable(R.drawable.o2)));
}
提前致谢。
【问题讨论】: