根据编号显示错误提示信息.的尝试



我是java和Android的新手。在下面的代码片段中,当用户名&密码不正确。现在我需要在错误信息中添加一些额外的信息2次错误的尝试后。如果我需要设置一个计数器来识别尝试?我该怎么做?

public void testBadCredentials() throws Exception {
    RestClientFactoryTest.setPrefixAllInstances("login-failure");
    XMLRPCFactoryTest.setPrefixAllInstances("login-failure");
    mSolo.enterText(0, "test"); //username 
    mSolo.enterText(1, "test"); //password
    mSolo.clickOnText(mSolo.getString(R.string.sign_in));
    boolean errorMessageFound = mSolo.searchText(mSolo.getString(R.string.username_or_password_incorrect));
    assertTrue("Error message not found", errorMessageFound);
}
 private static n0_attamp = 0;
public void testBadCredentials() throws Exception {
n0_attamp++;
RestClientFactoryTest.setPrefixAllInstances("login-failure");
XMLRPCFactoryTest.setPrefixAllInstances("login-failure");
mSolo.enterText(0, "test"); //username 
mSolo.enterText(1, "test"); //password
mSolo.clickOnText(mSolo.getString(R.string.sign_in));
boolean errorMessageFound = mSolo.searchText(mSolo.getString(R.string.username_or_password_incorrect));
if(n0_attamp = 3)
{ 
  assertTrue("3rd try", errorMessageFound);
  //reinitialize counter
   n0_attamp = 0; 
 }
 else
assertTrue("Error message not found", errorMessageFound);
}

最新更新