首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在使用ADB运行android测试时获取日志

如何在使用ADB运行android测试时获取日志
EN

Stack Overflow用户
提问于 2021-05-04 04:09:27
回答 1查看 112关注 0票数 0

我使用ADB在多个设备上并行运行测试:

代码语言:javascript
运行
复制
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

如果测试失败,通常会显示错误消息/堆栈跟踪,但并不总是如此。因此,将应用程序的日志保存在一个文件中会很有帮助。在测试完成后,我尝试了以下命令:

代码语言:javascript
运行
复制
adb -s 11.11.11.111:5555 logcat | grep "com.my.app.*" > app/build/reports/logcat.txt

但该命令只将系统日志保存在文件中,而不是我在Android Studio中运行测试时通常可以看到的日志(在Android Studio的logcat窗口中)。

EN

回答 1

Stack Overflow用户

发布于 2021-05-04 04:15:36

您可能只是忘记在adb logcat上添加-s 11.11.11.11x:5555选项。

代码语言:javascript
运行
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67375197

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档