我使用ADB在多个设备上并行运行测试:
adb -s 11.11.11.111:5555 shell "CLASSPATH=$(pm path androidx.test.services) app_process / androidx.test.services.shellexecutor.ShellMain am instrument -r -w -e targetInstrumentation com.my.app.debug.test/androidx.test.runner.AndroidJUnitRunner -e clearPackageData true -e numShards 2 -e shardIndex 0 -e debug false androidx.test.orchestrator/androidx.test.orchestrator.AndroidTestOrchestrator" &
adb -s 11.11.11.112:5555 shell "CLASSPATH=$(pm path androidx.test.services) app_process / androidx.test.services.shellexecutor.ShellMain am instrument -r -w -e targetInstrumentation com.my.app.debug.test/androidx.test.runner.AndroidJUnitRunner -e clearPackageData true -e numShards 2 -e shardIndex 1 -e debug false androidx.test.orchestrator/androidx.test.orchestrator.AndroidTestOrchestrator" &
wait
如果测试失败,通常会显示错误消息/堆栈跟踪,但并不总是如此。因此,将应用程序的日志保存在一个文件中会很有帮助。在测试完成后,我尝试了以下命令:
adb -s 11.11.11.111:5555 logcat | grep "com.my.app.*" > app/build/reports/logcat.txt
但该命令只将系统日志保存在文件中,而不是我在Android Studio中运行测试时通常可以看到的日志(在Android Studio的logcat窗口中)。
发布于 2021-05-04 04:15:36
您可能只是忘记在adb logcat上添加-s 11.11.11.11x:5555选项。
adb -s 11.11.11.111:5555 logcat | grep "com.my.app.*" > app/build/reports/logcat1.txt
adb -s 11.11.11.112:5555 logcat | grep "com.my.app.*" > app/build/reports/logcat2.txt
https://stackoverflow.com/questions/67375197
复制相似问题