查看開發人員裝置平台測試結果

本指南說明如何找出按照「Developer Device Platform 裝置執行」指南觸發的測試和可執行檔結果。

事前準備

以下步驟假設您已建立 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/) 提取的檔案。

使用網路瀏覽器

如需完整詳細資料,請從測試輸出內容將網址載入至包含測試結果的 bucket。應類似於: 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 控制台網頁介面中瀏覽記錄,請按照下列步驟操作:

  1. 在瀏覽器中,將您在 gcloud config set project 指令中使用的專案名稱附加至網址 https://console.cloud.google.com/?project=,然後載入該網頁。
  2. 展開左上方的選單。
  3. 找到「Cloud Storage」。
  4. 在儲存空間選單中選取「Bucket」。
  5. 在第一欄中,按一下專案名稱。
  6. 按一下「自動化」。
  7. 按一下「工作階段」。
  8. 在「Filter」(篩選器) 欄位中,貼上最新測試執行的工作階段 ID (請參閱測試輸出內容)。
  9. 按一下產生的工作階段名稱。
  10. 選取「job-job-*」即可查看 junit.xml (適用於 Android 檢測和 iOS XCTest 執行),其中包含工作中的所有執行和測試案例合併結果詳細資料。
  11. 開啟 execution-* (或設定不穩定測試重試次數時,開啟 execution-*-rerun-*,並使用 --flaky-test-attempts),即可查看每個執行作業或分片的詳細資料。視工作階段類型和設定的旗標而定,這個資料夾可能包含多個構件。詳情請參閱「瞭解結果」。
  12. 請前往公開和已驗證的網址,瞭解結果。

檔案結構

查看 Cloud Storage bucket 中的記錄檔,進一步瞭解工作階段執行情況。檔案結構如下所示:

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 裝置系統記錄,以及在測試執行期間發生程序當機時的任何 .ips 診斷當機報告。
  • 使用 --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。

佐證文件

後續步驟

接下來,請試用 Developer Device Platform Device Streaming API。