我想在模拟器上从本地驱动器安装安卓应用并运行Espresso测试已经存在的应用程序。有没有办法跳过Espresso测试中的应用程序安装?
我想在模拟器上从本地驱动器安装安卓应用并运行Espresso测试已经存在的应用程序。有没有办法跳过Espresso测试中的应用程序安装?
您可以使用ADB安装您的APK,并手动启动测试:
$ adb install myapp.apk (1)
$ adb install myapp-androidTest-unaligned.apk (2)
$ adb shell am instrument -w com.myapp.test/android.support.test.runner.AndroidJUnitRunner (3)
testInstrumentationRunner
。回答您的问题,如果apk和测试apk已经在您的设备上(可能是通过之前运行./gradlew connectedAndroidTest
),则您可能不需要执行步骤1和2。
参考此Android文档页面,它介绍了更多关于adb shell am instrument命令的信息。