Android automated testing - robotium (3) EditText control

In order to better try Robotium's AIP, I wrote some android controls myself and provided tests.

EditText control:

Steps:

1. Click on the EditText control

2. Enter text content: This is EditTextActivity

3. Click the Submit button

Validation: Page returns text: This is EditTextActivity

 
  1. publicvoid testUI() throws Exception {  
  2.     this.EditText(); 
  3.  
  4. publicvoid EditText(){  
  5.     boolean expected = true
  6.     solo.clickOnButton("EditText"); 
  7.     solo.enterText(0"This is EditTextActivity"); 
  8.     solo.clickOnButton("Submit"); 
  9.     boolean actual = solo.searchText("This is EditTextActivity"); 
  10.     assertEquals("This is not found",expected,actual); 
  11.     solo.goBack(); 

 

assertEquals has three parameters

assertEquals(String message,boolean expected, boolean actual)

message: the message returned when an error occurs

expected: expected result, a boolean value

actual: the actual result, also a boolean value

If the expected and actual values ​​are the same (both can be false), the test passes, otherwise it fails.

This article is from the " Xiao Maozi " blog, please be sure to keep this source http://xiaomaozi.blog.51cto.com/925779/917054

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326395871&siteId=291194637