2014-03-27 2 views
0

저는 자바와 안드로이드를 처음 접했습니다. 아래 코드에서 사용자 이름이 & 일 때 오류 메시지가 표시됩니다. 잘못된 시도를 한 후에 오류 메시지에 몇 가지 추가 정보를 추가해야합니다. 시도를 식별하기 위해 카운터를 설정해야합니까? 어떻게 할 수 있습니까?번호에 따라 오류 메시지를 표시하십시오. 시도해?

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); 
} 

답변

0
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); 
} 
관련 문제