报告:
--------------------------------执行测试前------------------------------------------
INSTRUMENTATION_STATUS: numtests=4
INSTRUMENTATION_STATUS: stream=
com.yang.clicktest.UiClickTest:
INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
INSTRUMENTATION_STATUS: test=test2
INSTRUMENTATION_STATUS: class=com.yang.clicktest.UiClickTest
--------------------------------执行测试中------------------------------------------
INSTRUMENTATION_STATUS: current=1
INSTRUMENTATION_STATUS_CODE: 1
INSTRUMENTATION_STATUS: numtests=4
INSTRUMENTATION_STATUS: stream=.
INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
INSTRUMENTATION_STATUS: test=test2
INSTRUMENTATION_STATUS: class=com.yang.clicktest.UiClickTest
INSTRUMENTATION_STATUS: current=1
INSTRUMENTATION_STATUS_CODE: 0
INSTRUMENTATION_STATUS: numtests=4
INSTRUMENTATION_STATUS: stream=
INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
INSTRUMENTATION_STATUS: test=test3
INSTRUMENTATION_STATUS: class=com.yang.clicktest.UiClickTest
INSTRUMENTATION_STATUS: current=2
INSTRUMENTATION_STATUS_CODE: 1
INSTRUMENTATION_STATUS: numtests=4
INSTRUMENTATION_STATUS: stream=
Error in test3:
com.android.uiautomator.core.UiObjectNotFoundException: UiSelector[TEXT=Contacts_xxx]
at com.android.uiautomator.core.UiObject.getVisibleBounds(UiObject.java:811)
at com.android.uiautomator.core.UiObject.dragTo(UiObject.java:216)
at com.yang.clicktest.UiClickTest.test3(UiClickTest.java:40)
at com.android.uiautomator.testrunner.UiAutomatorTestRunner.start(UiAutomatorTestRunner.java:160)
at com.android.uiautomator.testrunner.UiAutomatorTestRunner.run(UiAutomatorTestRunner.java:96)
at com.android.commands.uiautomator.RunTestCommand.run(RunTestCommand.java:91)
at com.android.commands.uiautomator.Launcher.main(Launcher.java:83)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:255)
INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
INSTRUMENTATION_STATUS: test=test3
INSTRUMENTATION_STATUS: class=com.yang.clicktest.UiClickTest
INSTRUMENTATION_STATUS: stack=com.android.uiautomator.core.UiObjectNotFoundException: UiSelector[TEXT=Contacts_xxx]
at com.android.uiautomator.core.UiObject.getVisibleBounds(UiObject.java:811)
at com.android.uiautomator.core.UiObject.dragTo(UiObject.java:216)
at com.yang.clicktest.UiClickTest.test3(UiClickTest.java:40)
at com.android.uiautomator.testrunner.UiAutomatorTestRunner.start(UiAutomatorTestRunner.java:160)
at com.android.uiautomator.testrunner.UiAutomatorTestRunner.run(UiAutomatorTestRunner.java:96)
at com.android.commands.uiautomator.RunTestCommand.run(RunTestCommand.java:91)
at com.android.commands.uiautomator.Launcher.main(Launcher.java:83)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:255)
INSTRUMENTATION_STATUS: current=2
INSTRUMENTATION_STATUS_CODE: -1
INSTRUMENTATION_STATUS: numtests=4
INSTRUMENTATION_STATUS: stream=
INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
INSTRUMENTATION_STATUS: test=testClick
INSTRUMENTATION_STATUS: class=com.yang.clicktest.UiClickTest
INSTRUMENTATION_STATUS: current=3
INSTRUMENTATION_STATUS_CODE: 1
INSTRUMENTATION_STATUS: numtests=4
INSTRUMENTATION_STATUS: stream=.
INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
INSTRUMENTATION_STATUS: test=testClick
INSTRUMENTATION_STATUS: class=com.yang.clicktest.UiClickTest
INSTRUMENTATION_STATUS: current=3
INSTRUMENTATION_STATUS_CODE: 0
INSTRUMENTATION_STATUS: numtests=4
INSTRUMENTATION_STATUS: stream=
INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
INSTRUMENTATION_STATUS: test=test_not_found_test
INSTRUMENTATION_STATUS: class=com.yang.clicktest.UiClickTest
INSTRUMENTATION_STATUS: current=4
INSTRUMENTATION_STATUS_CODE: 1
INSTRUMENTATION_STATUS: numtests=4
INSTRUMENTATION_STATUS: stream=
Failure in test_not_found_test:
junit.framework.AssertionFailedError
at com.yang.clicktest.UiClickTest.test_not_found_test(UiClickTest.java:44)
at com.android.uiautomator.testrunner.UiAutomatorTestRunner.start(UiAutomatorTestRunner.java:160)
at com.android.uiautomator.testrunner.UiAutomatorTestRunner.run(UiAutomatorTestRunner.java:96)
at com.android.commands.uiautomator.RunTestCommand.run(RunTestCommand.java:91)
at com.android.commands.uiautomator.Launcher.main(Launcher.java:83)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:255)
INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
INSTRUMENTATION_STATUS: test=test_not_found_test
INSTRUMENTATION_STATUS: class=com.yang.clicktest.UiClickTest
INSTRUMENTATION_STATUS: stack=junit.framework.AssertionFailedError
at com.yang.clicktest.UiClickTest.test_not_found_test(UiClickTest.java:44)
at com.android.uiautomator.testrunner.UiAutomatorTestRunner.start(UiAutomatorTestRunner.java:160)
at com.android.uiautomator.testrunner.UiAutomatorTestRunner.run(UiAutomatorTestRunner.java:96)
at com.android.commands.uiautomator.RunTestCommand.run(RunTestCommand.java:91)
at com.android.commands.uiautomator.Launcher.main(Launcher.java:83)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:255)
INSTRUMENTATION_STATUS: current=4
INSTRUMENTATION_STATUS_CODE: -2
INSTRUMENTATION_STATUS: stream=
--------------------------------执行测试后------------------------------------------
Test results for WatcherResultPrinter=..E..F //既有测试代码错误,也有断言错误
Time: 31.957
FAILURES!!!
Tests run: 4, Failures: 1, Errors: 1 // Failures 代表断言的个数, Errors 代表测试脚本的错误数
INSTRUMENTATION_STATUS_CODE: -1
测试脚本:
package com.yang.clicktest;
import com.android.uiautomator.core.UiDevice;
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
public class UiClickTest extends UiAutomatorTestCase {
public void testClick() throws UiObjectNotFoundException{
pressBack();
UiDevice.getInstance().pressHome();
UiObject alarm = new UiObject(new UiSelector().resourceId("com.sec.android.app.clockpackage:id/alarm_item"));
alarm.clickBottomRight();
UiObject cancel = new UiObject(new UiSelector().resourceId("com.sec.android.app.clockpackage:id/Menu_Cancel"));
cancel.click();
}
public void test2() throws UiObjectNotFoundException{
pressBack();
UiDevice.getInstance().pressHome();
UiObject Contacts = new UiObject(new UiSelector().text("Contacts"));
Contacts.dragTo(150, 250, 5);
}
public void test3() throws UiObjectNotFoundException{
pressBack();
UiDevice.getInstance().pressHome();
UiObject Contacts = new UiObject(new UiSelector().text("Contacts_xxx")); // 测试脚本错误,找不到这个object
Contacts.dragTo(150, 250, 5);
}
public void test_not_found_test(){
assertTrue(false); // 断言错误
}
void pressBack(){
UiDevice.getInstance().pressBack();
UiDevice.getInstance().pressBack();
UiDevice.getInstance().pressBack();
UiDevice.getInstance().pressBack();
UiDevice.getInstance().pressBack();
}
}