0
我想從命令行進行uiautomator 2.0測試。我的步驟如下:未能使用uiautomator 2.0測試
創建儀表工程,代碼如下:
package com.android.uiautomator.client; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import android.app.Application; import android.app.Instrumentation; import android.content.Context; import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; import android.test.ApplicationTestCase; @RunWith(AndroidJUnit4.class) public class Initialize { @Test public void testStartServer() { System.out.println("this is the test"); } }
使用gradlew生成測試APK
安裝測試APK到Android模擬器
adb shell push ${apkPath}/test.apk /data/local/tmp/com.android.test adb shell pm install -r /data/local/tmp/com.android.test
檢查測試a PK安裝成功。我可以找到安裝的apk。
adb shell pm list packages
安裝後,我檢查儀器在模擬器,但我cant't找到有關測試APK的儀表。這將導致失敗的執行命令:
adb shell am instrument -e class com.android.uiautomator.client.Initialize -w com.android.uiautomator.client.test/android.support.test.runner.AndroidJUnitRunner
所以,我很困惑。爲什麼安裝測試apk後無法找到儀器?
是的,我試過了。但我仍然找不到安裝測試的安裝程序apk – kobe990
然後,儀器沒有安裝或者沒有安裝該軟件包,請移除grep過濾器並查看所有已安裝的 –