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
- publicvoid testUI() throws Exception {
- this.EditText();
- }
- publicvoid EditText(){
- boolean expected = true;
- solo.clickOnButton("EditText");
- solo.enterText(0, "This is EditTextActivity");
- solo.clickOnButton("Submit");
- boolean actual = solo.searchText("This is EditTextActivity");
- assertEquals("This is not found",expected,actual);
- 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