Espresso 测试检查 Listview 中 TextView 的字符串值是否不存在
Espresso Testing check if string value of TextView in Listview does not exist
我有一个包含 ArrayList 的 ListView。 Food.class 包含字符串值,例如 FoodName。现在我想检查从 ListView 中删除一行后,值 FoodName 是否不再存在于特定位置。我尝试了以下不起作用的代码:
onData(anything())
.inAdapterView(withId(R.id.list))
.atPosition(0)
.onChildView(withId(R.id.food_name))
.check("I don't know how to check if string value of food_name which I deleted before does not exist here anymore")
感谢帮助!
你可以这样做:
onData(anything())
.inAdapterView(withId(R.id.list))
.atPosition(0)
.onChildView(withId(R.id.food_name))
.check(matches(not(withText("Your old text"))));
或
onData(anything())
.inAdapterView(withId(R.id.list))
.atPosition(0)
.check(matches(not(hasDescendant(withText("Your old text")))));
PS。我查看了expresso cheatsheet,当我遇到这类问题时非常有用。
我有一个包含 ArrayList 的 ListView。 Food.class 包含字符串值,例如 FoodName。现在我想检查从 ListView 中删除一行后,值 FoodName 是否不再存在于特定位置。我尝试了以下不起作用的代码:
onData(anything())
.inAdapterView(withId(R.id.list))
.atPosition(0)
.onChildView(withId(R.id.food_name))
.check("I don't know how to check if string value of food_name which I deleted before does not exist here anymore")
感谢帮助!
你可以这样做:
onData(anything())
.inAdapterView(withId(R.id.list))
.atPosition(0)
.onChildView(withId(R.id.food_name))
.check(matches(not(withText("Your old text"))));
或
onData(anything())
.inAdapterView(withId(R.id.list))
.atPosition(0)
.check(matches(not(hasDescendant(withText("Your old text")))));
PS。我查看了expresso cheatsheet,当我遇到这类问题时非常有用。