UiAutomator 测试报告查看与分析



报告:

--------------------------------执行测试前------------------------------------------

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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值