@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无法处理动画,因此我做了以下操作: - 关闭我的测试设备的窗口动画、转换动画和动画器持续时间比例,全部设置为OFF(这个方法没有起作用) - 然后我尝试在我的代码中添加一个标志,例如espresso_testing = true。如果为true,则我的代码将跳过调用所有startAnimation()函数调用。--->这个方法有效。但是,在编写Espresso测试用例时,有一个要求,即我不能更改我的应用程序上的代码。以上是一个测试案例。
还有其他方法吗?谢谢!