我已写过ff。行为测试。是否正在编写一个等待31分钟的测试,以涵盖可接受的过期情况和良好做法?
public class ExpiredTokenBehaviorTestCase extends ActivityInstrumentationTestCase2<ResetPasswordActivity> {
protected Solo solo;
public final static int TOKEN_EXPIRATION_MINS = 31 * 1000 * 60; // 31 minutes, sanity check, can't do math
public ExpiredTokenBehaviorTestCase() {
super(ResetPasswordActivity.class);
}
@Override
protected void setUp() throws Exception {
solo = new Solo(getInstrumentation(), getActivity());
}
@Override
protected void tearDown() throws Exception {
solo.finishOpenedActivities();
}
/**
* Expired
*/
public void testExpiredPassword() {
solo.typeText(0, "+639224424166"); // type in mobile number to send the verification code
solo.clickOnButton("Next >"); // click next
if (solo.waitForActivity(VerificationActivity.class)) {
solo.typeText(0, "ab2f1de"); // valid code
solo.sleep(TOKEN_EXPIRATION_MINS); // wait for token to expire
solo.clickOnButton("Next >"); // now click on next
solo.waitForText("Verification code expired"); // should show the code expired
}
}
}
答案 0 :(得分:3)
自动化测试应该尽快运行。它们运行得越快,运行它们就越便宜。通过这种方式,您可以让它们经常运行,并为您提供有关成功和失败的快速反馈。快速执行的测试还可以使持续集成运行简短且易于管理,这是一项宝贵的奖励。
31分钟对于测试提供反馈来说太长了。相反,您应该能够在测试中控制令牌的到期时间,并生成即时到期的令牌,以便您可以立即测试到期场景,而无需等待。