Integrating uiautomator test case with application code in Android

丶灬走出姿态 提交于 2019-12-10 10:18:51

问题


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. /tools/android create uitest-project -n -t 1 -p

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

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

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

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


回答1:


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

Example:

#!/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



回答2:


You can check Uiautomator-bot, it does what you are looking for. You don't have to use any command line. It can also run test cases on multiple devices simultaneously. For more info check this link.



来源:https://stackoverflow.com/questions/15129125/integrating-uiautomator-test-case-with-application-code-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!