サソリ*_*サソリ 12 java android android-studio android-espresso
我在测试我的应用时遇到问题.我创建了一个espresso测试,它应该会失败,因为每当我在模拟器中启动我的应用程序时,我都会得到预期的行为.有我的测试:
onView(withText("wrong answer")).perform(click());
onView(withId(R.id.nextQuestionButton)).check(matches(isEnabled()));
Run Code Online (Sandbox Code Playgroud)
当启动测试,没有任何报道,而nextQuestionButton应该不会在点击其文字是"错误的答案"的单选按钮被激活.
pio*_*543 29
根据我的理解,你希望它像这样工作:
如果
nextQuestionButton启用IS,则执行以下操作:
- 点击'错误答案',
- 检查是否
nextQuestionButton更改声明为未启用.
如果是这样,代码应该是这样的:
onView(withId(R.id.nextQuestionButton)).check(matches(isEnabled()));
onView(withText("wrong answer")).perform(click());
onView(withId(R.id.nextQuestionButton)).check(matches(not(isEnabled())));
Run Code Online (Sandbox Code Playgroud)
Espresso允许您在测试中使用Hamcrest匹配器.
请检查一下(如果您还没有这样做):
浓缩咖啡2.1.Espresso Cheat Sheet Master
根据你帖子的这个片段:
启动测试时,不报告任何内容,而
nextQuestionButton在单击radioButton其文本为"错误答案" 时不应启用.
这意味着您没有设置禁用下一个问题按钮,因此Espresso通过了此测试.
| 归档时间: |
|
| 查看次数: |
8701 次 |
| 最近记录: |