本指南介绍了如何查找按照Developer Device Platform Device Run 指南触发的测试和可执行文件的结果。
准备工作
这些步骤假定您已创建 Google Cloud 项目,完成了 Developer Device Platform 快速入门指南中的设置步骤,并在终端中使用 gcloud 进行了身份验证。
在命令行中
使用以下命令和您的会话 ID 查看测试或可执行文件结果的基本摘要:
gcloud beta device-run sessions describe SESSION_ID
这将返回如下所示的结果:
Session SESSION_ID finished with result [FAILED].
Result files are stored at [https://console.cloud.google.com/storage/browser/BUCKET_NAME/automation/sessions/SESSION_ID/].
JOB NAME EXECUTION NAME EXECUTION RESULT
job-000 all FAILED: 2 test cases failed, 5 passed
job-001 all PASS
对于您使用 --device 标志指定的每个设备类型 ID,系统都会在会话中生成一个作业。作业索引将遵循设备 ID 的顺序。测试失败是预料之中的,应通过迭代改进和运行来调查和解决。
如需获取有关会话的其他详细信息,请将 --full 附加到之前运行的 describe 命令,如下所示:
gcloud beta device-run sessions describe SESSION_ID --full
这将返回如下所示的结果:
Android 插桩
name: projects/PROJECT_ID/locations/global/sessions/session-370961e1
sessionConfig:
displayName: instrumentation-session
jobConfigs:
- action:
androidInstrumentationTest:
testInstallable:
files:
- gcsInputFile:
path: gs://BUCKET_NAME/automation/inputs/2026-07-30_11:28.31915956_8514/app_name_test.apk
allocationConfig:
deviceConfigs:
- actions:
- androidInstallPackages:
installables:
- files:
- gcsInputFile:
path: gs://BUCKET_NAME/automation/inputs/2026-07-30_11:28.31915956_8514/app_name.apk
- androidLogcat: {}
requirement:
deviceId: pa3q-35
displayName: job-000
outputDirectoryConfig:
gcsOutputDirectory:
path: gs://BUCKET_NAME/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://PROJECT_ID-devicerun/automation/sessions/session-370961e1/job-000/execution-000/logcat.txt
- gcsOutputFile:
path: gs://PROJECT_ID-devicerun/automation/sessions/session-370961e1/job-000/execution-000/instrument.log
- gcsOutputFile:
path: gs://PROJECT_ID-devicerun/automation/sessions/session-370961e1/job-000/execution-000/junit.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
Android 可执行文件
name: projects/PROJECT_ID/locations/global/sessions/session-8a41c2b0
sessionConfig:
displayName: android-executable-session
jobConfigs:
- action:
androidNativeBinary:
androidNativeBinary:
gcsInputFile:
path: gs://BUCKET_NAME/automation/inputs/2026-07-30_11:28.31915956_8514/my_executable
args:
- --example_flag=/data/local/tmp/example_value
- --threads=4
allocationConfig:
deviceConfigs:
- actions:
- androidLogcat: {}
- androidPushFiles:
fileConfigs:
- destinationPath: /data/local/tmp/model.tflite
sourceFile:
gcsInputFile:
path: gs://BUCKET_NAME/automation/inputs/2026-07-30_11:28.31915956_8514/model.tflite
requirement:
deviceId: shiba-34
displayName: job-000
outputDirectoryConfig:
gcsOutputDirectory:
path: gs://BUCKET_NAME/automation/sessions
sessionReport:
endTime: '2026-07-30T03:30:05.838Z'
id: 4b9120ec-fdf7-418a-a9b9-b6fa98dff838
jobReports:
- displayName: job-000
endTime: '2026-07-30T03:30:04.601Z'
executionReports:
- displayName: execution-000
endTime: '2026-07-30T03:30:02.151Z'
id: 19a267dd-dde9-4ea9-b2cd-738049083fc9
outputFiles:
- gcsOutputFile:
path: gs://PROJECT_ID-devicerun/automation/sessions/session-8a41c2b0/job-000/execution-000/logcat.txt
- gcsOutputFile:
path: gs://PROJECT_ID-devicerun/automation/sessions/session-8a41c2b0/job-000/execution-000/output.log
result:
resultType: PASSED
startTime: '2026-07-30T03:29:32.769Z'
status:
statusType: DONE
id: 8874e37a-2928-4aaf-abba-3a8b6bae853b
result:
resultType: PASSED
startTime: '2026-07-30T03:28:53.756Z'
status:
statusType: DONE
result:
resultType: PASSED
startTime: '2026-07-30T03:28:52.702Z'
status:
statusType: DONE
iOS XCTest
以下是启用所有标志的实时 iOS XCTest 运行中 gcloud beta device-run sessions
describe SESSION_ID --full 的实际经过排查的输出:
name: projects/PROJECT_ID/locations/global/sessions/session-4b941167-5629-4abb-a8a1-a9814bf16847
sessionConfig:
displayName: xctest-session
jobConfigs:
- action:
iosXcTest:
testsZip:
gcsInputFile:
path: gs://BUCKET_NAME/automation/inputs/2026-10-09_11:33.01234567_ABCD/MyTests.zip
allocationConfig:
deviceConfigs:
- actions:
- iosInstallPackages:
ipas:
- gcsInputFile:
path: gs://BUCKET_NAME/automation/inputs/2026-10-09_11:33.01234567_ABCD/AdditionalApp.ipa
requirement:
deviceId: iphonese3-18-4
displayName: job-000
outputDirectoryConfig:
gcsOutputDirectory:
path: gs://BUCKET_NAME/automation/sessions
在此输出中,找到在 .../artifacts/output.txt(不含 com.example.app/Documents/)处为被测应用拉取的文件。
在网络浏览器中
如需了解完整详情,请从测试输出中加载指向包含测试结果的存储桶的网址。它应类似于:
https://console.cloud.google.com/storage/browser/BUCKET_NAME/automation/sessions/SESSION_ID/
会话在存储空间中以以下路径格式显示:
gs://BUCKET_NAME/automation/sessions/SESSION_ID/job-000/EXECUTION_ID/
导航中
如需在 Google Cloud 控制台网页界面中浏览日志,请按照以下步骤操作:
- 在浏览器中,将
gcloud config set project命令中使用的项目名称附加到网址https://console.cloud.google.com/?project=,然后加载该页面。 - 展开左上角的菜单。
- 找到 Cloud Storage。
- 从存储菜单中选择存储桶。
- 在第一列中,点击您的项目名称。
- 点击自动化。
- 点击会话。
- 在过滤条件字段中,粘贴最新测试运行中的会话 ID(请参阅测试输出)。
- 点击生成的会话名称。
- 选择 job-* 以查看
junit.xml(适用于 Android 插桩和 iOS XCTest 运行),其中包含作业中所有执行和测试用例的合并结果详细信息。 - 打开 execution-*(或 execution-*-rerun-*,如果使用
--flaky-test-attempts配置了不可靠的测试重试),查看每个单独执行或分片的细分。此文件夹可能包含大量工件,具体取决于您的会话类型和配置的标志。如需了解详情,请参阅了解结果。 - 访问公开网址和经过身份验证的网址,了解结果。
文件结构
探索 Cloud Storage 存储桶中的日志文件,详细了解会话执行情况。文件结构如下所示:
Android 插桩
- gs://BUCKET_NAME/automation
- inputs/
- 2026-05-29_10:13.026220_JZTM
- app.apk
- test.apk
- sessions/
- SESSION_ID
- job-000/
- junit.xml
- execution-000/
- artifacts/
- sdcard/
- output.txt
- bugreport.zip
- dumpsys.txt
- instrument.log
- junit.xml
- logcat.txt
- video.mp4
- execution-001/
- instrument.log
- junit.xml
- logcat.txt
- video.mp4
- job-001/
- SESSION_ID
Android 可执行文件
- gs://BUCKET_NAME/automation
- inputs/
- 2026-05-29_10:13.026220_JZTM
- my_executable
- model.tflite
- sessions/
- SESSION_ID
- job-000/
- execution-000/
- artifacts/
- data/
- local/
- tmp/
- results.json
- bugreport.zip
- dumpsys.txt
- logcat.txt
- output.log
- video.mp4
- job-001/
- SESSION_ID
iOS XCTest
- gs://BUCKET_NAME/
- automation/
- inputs/
- 2026-10-09_11:33.01234567_ABCD/
- AdditionalApp.ipa
- MyTests.zip
- data.txt
- sessions/
- SESSION_ID/
- job-000/
- execution-000/
- artifacts/
- output.txt
- junit.xml
- system.log
在此输出中,了解 artifacts/ 下的拉取路径。对于 --paths-to-pull=com.example.app:/Documents/output.txt,从被测应用 (AUT) 拉取时,该服务会去除 /Documents 并将文件直接放置在 artifacts/output.txt(而非 artifacts/com.example.app/Documents/output.txt)中。如果从其他应用 (--additional-apps) 拉取,则会放置在 artifacts/<bundle_id>-genfiles/output.txt 中。
解读结果
对于 Android 插桩和 iOS XCTest 运行,输出中生成的 junit.xml 文件是标准 JUnit XML 文件。执行级 junit.xml 会写入每个 execution-* 目录,合并的 junit.xml 会写入每个 job-* 目录。这些文件包含每个测试方法的结果,让您可以查看每个测试方法的具体通过或失败状态、执行时间和错误跟踪。您可以轻松地将这些文件与大多数持续集成和持续交付 (CI/CD) 系统以及测试报告工具集成并进行解析。
除了结构化测试结果之外,每个 execution-* 目录还包含特定于平台的日志和工件:
- Android 插桩运行包括
instrument.log(用于原始插桩运行程序输出)和logcat.txt(用于设备级 Android 系统日志)。如果使用--bugreport、--dumpsys或--video启用,则执行目录还包含bugreport.zip、dumpsys.txt和屏幕视频录制内容。 - Android 可执行文件运行包括
output.log(用于捕获可执行文件写入的标准输出 [stdout] 和标准错误 [stderr])和logcat.txt(默认情况下为每个 Android 作业收集,用于捕获设备范围内的 Android 系统日志),以及任何可选的--bugreport、--dumpsys或--video工件。 - iOS XCTest 运行包括
system.log(默认情况下为每个 iOS XCTest 作业收集),用于捕获原始 iOS 设备 syslog,以及在测试执行期间进程崩溃时的任何.ips诊断崩溃报告。如果使用--video启用,则每个录制的界面测试用例视频都会存储在testcases/TEST_CLASS/TEST_METHOD/video.mp4中。 - 使用
--paths-to-pull指定的拉取的设备文件存储在执行目录的artifacts/子文件夹下。- 对于 Android 运行,拉取的文件会保留其在
artifacts/下的设备路径(例如artifacts/sdcard/output.txt或artifacts/data/local/tmp/results.json)。 - 对于 iOS XCTest 运行,使用
--paths-to-pull=BUNDLE_ID:DEVICE_PATH从应用数据容器中拉取的文件会按软件包 ID 整理到artifacts/下:- 如果
com.example.app是被测应用,则会直接保存在artifacts/output.txt中。 - 如果
com.example.app是附加应用 (--additional-apps),则会保存在artifacts/com.example.app-genfiles/output.txt中。
- 如果
- 对于 Android 运行,拉取的文件会保留其在
证明文件
后续步骤
接下来,请试用我们的 Developer Device Platform Device Streaming API。