新建測試工程java
UiTest-->android
導入android.jar uiautoator.jar junit.jarshell
新建testcase類:windows
public class Test extends UiAutomatorTestCase {
public void testDemo() throws UiObjectNotFoundException {
// Simulate a short press on the HOME button.
getUiDevice().pressHome();
}
}
2.建立build.xml文件eclipse
cmd->>D:\Program Files\adt-bundle-windows-x86-20131030\sdk\tools>android create uitest-project -n UiTest -t 1 -p D:\project\eclipse--java\UiTest測試
刷新UiTest工程,雙擊build.xml 修改 <project name="Uiautomator" default="help"> 中的 help爲bulid,保存便可.ui
接下來就能夠又鍵進行ant build 在UiTest工程的bin目錄下會生成UiTest.jarxml
3.push jar到手機,用uiautomator 執行ip
cmd->>adb push UiTest.jar /data/local/tmpget
-->>adb shell uiautomator runtest Uitest.jar -c com.UiTest.Test