【发布时间】:2017-05-03 04:28:41
【问题描述】:
@Test
public void test3_PaySuccessful(){
init();
ViewInteraction amountEditText = onView(
allOf(withId(R.id.et_amount), isDisplayed()));
amountEditText.perform(replaceText("SGD 0.010"), closeSoftKeyboard());
//, withText("Proceed")
ViewInteraction appCompatButton = onView(
allOf(withId(R.id.btn_confirm), isDisplayed()));
appCompatButton.perform(click());
//, withText("Pay")
ViewInteraction appCompatButton2 = onView(
allOf(withId(R.id.btn_confirm), isDisplayed()));
appCompatButton2.perform(click());
//dialog
ViewInteraction appCompatButton3 = onView(
allOf(withId(R.id.confirm_button), withText("Confirm"), isDisplayed()));
appCompatButton3.perform(click());
//have to disable animation in order to pass this.
intended(CoreMatchers.allOf(hasComponent(PaymentSelectionActivity2.class.getName())));
}
我在使用涉及动画的视图进行 Espresso 测试时遇到问题,我知道 Espresso 无法处理动画,所以我在下面做了。 - 禁用我的测试设备窗口动画、过渡动画和动画持续时间比例都设置为关闭(这不起作用) - 然后我尝试在我的代码中添加一个标志,例如。 espresso_testing = 真。如果为真,我的代码将跳过调用所有 startAnimation() 函数调用。 ---> 这是有效的。但是,要求我在编写 espresso 测试用例时不能更改我的应用程序上的代码。包括上面的一个测试用例。
还有其他方法可以做到这一点吗?提前致谢。
【问题讨论】:
-
检查这个。它非常快stackoverflow.com/a/56198539/4797289
标签: android animation android-testing android-espresso