整合uiautomator测试用例与应用code Android中 [英] Integrating uiautomator test case with application code in Android

查看:184
本文介绍了整合uiautomator测试用例与应用code Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的Eclipse IDE。 这是我的$ C $下uiautomator测试用例:

I am using Eclipse IDE. Here is my code for uiautomator testcase:

public class caltest extends UiAutomatorTestCase {

    public void testDemo() throws UiObjectNotFoundException, IOException {

    //mytesstcode

    }
}

要运行这个测试我必须发出命令行下​​面的命令:

To run this test i have to issue following commands from command line:

  1. /工具/ Android的创建uitest项目-t -n 1 -p

  1. /tools/android create uitest-project -n -t 1 -p

转到项目目录中build.xml文件所在,建立自己的试验瓶。 ---> Ant构建

Go to the project directory where your build.xml file is located and build your test JAR. ---> ant build

使用ADB push命令部署您生成的测试JAR文件到测试设备: ---> ADB推/数据/本地的/ tmp /

Deploy your generated test JAR file to the test device by using the adb push command: ---> adb push /data/local/tmp/

- >亚行外壳uiautomator的runTest jarname.jar -c caltest

---> adb shell uiautomator runtest jarname.jar -c caltest

有没有什么办法可以在不使用命令行,即在Eclipse IDE中或从Android应用程序中运行我的测试。

Is there any way i can run my test without using commandline i.e. from the eclipse ide or from within an android application.

推荐答案

目前不。我所做的,以简化这个过程是写一个bash脚本。

Not currently. What I did to simplify the process was to write a bash script.

例如:

#!/bin/bash -xe
ant clean build

adb push bin/AutomatedTests.jar /data/local/tmp/

adb shell uiautomator runtest /data/local/tmp/AutomatedTests.jar -c com.example.tests.SimpleTest

这篇关于整合uiautomator测试用例与应用code Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆