如何在模拟器上运行UIAutomator?

时间:2014-06-29 05:47:38

标签: android android-emulator uiautomator

我可以在真实设备上运行我的UIAutomator测试。以下是我采取的步骤:

  1. <sdk_dir>/sdk/tools/android create uitest-project -n <test_name> -t 1 -p <workspace_dir>/<test_name>
  2. cd <workspace_dir>/<test_name>
  3. ant build
  4. <platform-tools/adb push
  5. <workspace_dir>/<test_name>/bin/<test_name.jar> /data/local/tmp
  6. <platform-tools/adb shell uiautomator runtest <test_name.jar> -c <package_name.classname>
  7. 有谁知道如何在模拟器上执行测试? (我正在使用Mac - emulator64-arm)

1 个答案:

答案 0 :(得分:2)

您始终可以在Android设备模拟器上运行UIAutomator测试

您需要的只是找出连接到电脑的设备:

<platform-tools/adb devices
List of devices attached
emulator-5555 device
HTCDesireX device

获得模拟器的设备ID后,使用adb -s <emulator_id>代替adb,您的新步骤将是:

<platform-tools/adb -s emulator-5555 push <workspace_dir>/<test_name>/bin/<test_name.jar> /data/local/tmp
<platform-tools/adb -s emulator-5555 shell uiautomator runtest <test_name.jar> -c <package_name.classname>