本指南介绍如何查找按照 开发者设备平台设备运行指南触发的测试的结果。
准备工作
这些步骤假设您已创建 Google Cloud 项目,完成了开发者设备平台快速入门指南中的设置步骤,并在终端中通过 gcloud 完成了身份验证。
在命令行中
使用以下命令和您的会话 ID 查看测试结果的基本摘要:
gcloud beta device-run sessions describe your_session_id
返回的结果如下所示:
Session [session-number] finished with result [FAILED].
Result files are stored at [https://console.cloud.google.com/storage/browser/<your_project_id>/automation/sessions/session-number/].
JOB NAME EXECUTION NAME EXECUTION RESULT
job-000 all FAILED: 2 test cases failed, 5 passed
job-001 all PASS
对于您使用 --device 标志指定的每个设备类型 ID,系统都会在会话中生成一个作业。作业指数将按照设备 ID 的顺序排列。测试失败是预期情况,应通过迭代改进和运行来调查和解决。
gcloud beta device-run sessions describe your_session_id --full
返回的结果如下所示:
name: projects/your-project-id/locations/global/sessions/session-370961e1
sessionConfig:
displayName: instrumentation-session
jobConfigs:
- action:
androidInstrumentationTest:
testInstallable:
files:
- gcsInputFile:
path: gs://your-project-id-devicerun/automation/inputs/2026-07-30_11:28.31915956_8514/app_name_test.apk
allocationConfig:
deviceConfigs:
- actions:
- androidInstallPackages:
installables:
- files:
- gcsInputFile:
path: gs://your-project-id-devicerun/automation/inputs/2026-07-30_11:28.31915956_8514/app_name.apk
- androidLogcat: {}
requirement:
deviceId: pa3q-35
displayName: job-000
outputDirectoryConfig:
gcsOutputDirectory:
path: gs://your-project-id-devicerun/automation/sessions
sessionReport:
endTime: '2026-07-30T03:30:05.838Z'
id: 6587313f-fdf7-418a-a9b9-b6fa98dff838
jobReports:
- displayName: job-000
endTime: '2026-07-30T03:30:04.601Z'
executionReports:
- displayName: all
endTime: '2026-07-30T03:30:02.151Z'
id: 29b167dd-dde9-4ea9-b2cd-738049083fc9
outputFiles:
- gcsOutputFile:
path: gs://your-project-id-devicerun/automation/sessions/session-370961e1/job-000/execution-000/logcat.txt
- gcsOutputFile:
path: gs://your-project-id-devicerun/automation/sessions/session-370961e1/job-000/execution-000/instrument.log
- gcsOutputFile:
path: gs://your-project-id-devicerun/automation/sessions/session-370961e1/job-000/execution-000/test_result.xml
result:
cause:
summary:
message: One or more test assertions or test methods failed. Inspect the
test runner logs and structured test results for details.
reason: TEST_CASE_FAILURE
type: CUSTOMER
resultType: FAILED
startTime: '2026-07-30T03:29:32.769Z'
status:
progressMessages:
- 2 test cases failed, 5 passed
statusType: DONE
id: 7974e37a-2928-4aaf-abba-3a8b6bae853b
result:
cause:
summary:
message: Job has one or more failed tests. See execution reports for details.
reason: JOB_HAS_FAILED_TESTS
resultType: FAILED
startTime: '2026-07-30T03:28:53.756Z'
status:
statusType: DONE
result:
cause:
summary:
message: Session has one or more failed jobs. See job reports for details.
reason: SESSION_HAS_FAILED_JOBS
resultType: FAILED
startTime: '2026-07-30T03:28:52.702Z'
status:
statusType: DONE
在网络浏览器中
如需了解完整详情,请从测试输出中加载包含测试结果的相应网址。它应类似于:
https://console.cloud.google.com/storage/browser/storage/browser/<your_project_id>/automation/sessions/<session_id>
导航中
如需在 Google Cloud 控制台网页界面中浏览日志,请按以下步骤操作:
- 在浏览器中,将
gcloud config set project命令中使用的项目名称附加到网址https://console.cloud.google.com/?project=,然后加载该网页。 - 展开左上角的菜单。
- 找到 Cloud Storage。
- 从存储菜单中选择存储分区。
- 在第一列中,点击您的项目名称。
- 点击自动化。
- 点击会话。
- 在过滤条件字段中,粘贴最新一次测试运行的会话 ID(请参阅测试输出)。
- 点击生成的会话名称。
- 选择 job-* 可查看
test_result_merged.xml,其中包含所有测试用例的全面结果详情。 - 打开 execution-*,查看每个分片的细分信息。在此文件夹中,前往:
instrumentation.loglogcat.txttest_result.xml
- 访问公开网址和已验证的网址,了解测试结果。
文件结构
探索 Cloud Storage 存储桶中的日志文件,详细了解测试失败的原因。文件结构类似于:
- gs://my_project_id_devicerun/automation
- inputs/
- 2026-05-29_10:13.026220_JZTM
- app.apk
- test.apk
- sessions/
- session-number
- job-000/
- test_results_merged.xml
- execution-000/
- instrumentation.log
- test_result.xml
- logcat.txt
- video.mp4
- execution-001/
- instrumentation_output.txt
- junit.xml
- logcat.txt
- video.mp4
- job-001/
- session-number
解读结果
在输出中生成的 test_result.xml 或 test_result_merged.xml 文件是标准的 JUnit XML 文件。此文件包含每个测试方法的结果,可让您查看每个测试方法的具体通过或失败状态、执行时间和错误轨迹。您可以轻松地将此文件与大多数持续集成和持续交付 (CI/CD) 系统以及测试报告工具集成并进行解析。
支持文档
后续步骤
接下来,试用我们的开发者设备平台 Device Streaming API。