Skip to main content

テスト結果の展開と表示

CI ビルド後、テスト結果を 1 か所で確認できます。ワークフローに複数のテストステップがあっても、すべてのテストはビルドページに表示されます。私たちの目標は、Bitrise上でアクセス可能で実用的なテスト結果が得られるようにすることです。これにより、テスト失敗からの回復までの時間を短縮し、全体的な開発者体験を向上させることができます

テスト結果のデプロイ

最小限の設定でテスト結果をビルドページにデプロイします。要件はセットアップによって異なります。

  • Bitriseの公式テストステップを使ってテストを実行する

  • 他のステップを使用してテストを実行する

Bitriseの公式テストステップの結果をデプロイする

サポートされているテスト手順は次のとおりです。

これらのステップのいずれかを使用する場合は、次のものが揃っていることを確認してください Bitrise.io にデプロイしてください ワークフローにステップイン。Bitrise はテスト結果を自動的にビルドページにデプロイします

アタッチメントとフレークテスト

テストで添付ファイルが生成されたり、Bitriseに不安定なテストを表示させたい場合、 Bitrise.io にデプロイしてください ステップはバージョン 2.19.1 以降である必要があります。

他のステップの結果のデプロイ

他のステップを使用してテストを実行する場合 (たとえば、 スクリプト 完全にカスタム化されたテストソリューションの手順) については、追加の設定が必要です。

  1. テストを実行するステップをワークフローに追加します。

  2. を追加 テスト結果をテストレポートアドオンにエクスポートする ワークフローへのステップ。

  3. ステップを設定します。 テスト結果をテストレポートアドオンにエクスポートするステップを使用する

  4. お持ちであることを確認してください Bitrise.io にデプロイしてください ワークフローにステップイン。

    アタッチメントとフレークテスト

    テストで添付ファイルが生成されたり、Bitriseに不安定なテストを表示させたい場合、 Bitrise.io にデプロイしてください ステップはバージョン 2.19.1 以降である必要があります。

テスト結果の表示

リッチ HTML レポート

使用する場合 リッチ HTML テストレポート、それらはまだにあります アーティファクト タブ。

結果を表示するには、ビルドページを開いて、 テスト タブ。テストはステータスに応じてさまざまなタブに分類されます。

  • 失敗

  • 合格しました

  • スキップされました

  • エラー

  • 薄片状

デフォルトでは、Bitriseは失敗したテストのリストを表示します。これらの各カテゴリでテスト実行の詳細を表示できます

任意のテストをクリックして、テスト期間、出力、およびテストで生成された添付ファイルの詳細を確認します。

で不安定なテストを見ることができます 薄片状 タブ。不安定なテストとは、コードを変更しなくても失敗することもあれば成功することもあるテストです。テストが失敗し、その後も成功した場合 自動再試行、Bitriseはテストを不安定とマークし、以下で確認できます フレーク状 タブ。また、テストを再試行するたびの詳細と添付ファイルも表示されます

2025-09-23-test-run-example.png

Collating test attachments with test results

Many tests generate image files (screenshot tests, XCUITests, etc). Bitrise test reports automatically collates image files with associated test cases for Xcode tests (using the xcresult file).

However, if your test doesn't generate an xcresult file, you can still achieve the same thing by generating a JUnit XML file and using Bitrise Steps:

Workflow Editor

Configuration YAML

  1. Generate a JUnit.xml file from your tests.

    The general file structure should look something like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <testsuites time="15.682687">
        <testsuite name="Tests.Registration" time="6.605871">
            <testcase name="testCase1" classname="Tests.Registration" time="2.113871" />
        </testsuite>
    </testsuites>
  2. Add a <properties> element to associate an attachment with a testcase.

    The name attribute of the element must be set with a value attachment_# where # is the ordered index of the attachment file, and the value is the filename. Bitrise will show attachments for any test with the attachment properties, but it's most common to only attach screenshots to failed tests. Mark a test as failed with a <failure> element.

    <testcase name="testCase1" classname="Tests.Registration" time="2.113871" />
      <failure message="Assertion error message" type="AssertionError">
        Call stack printed here
      </failure>
      <properties>
        <property name="attachment_1" value="pp1.jpg" />
        <property name="attachment_2" value="pp2.jpg" />
      </properties>            
    </testcase>
  3. Add the Export test results to Test Reports Step to your Bitrise Workflow.

  4. Set a test name in the The name of the test input.

  5. Set the path to your JUnit XML file in the Test result search pattern input.

  6. Add a custom Script Step to your Workflow

  7. In the Script content input, add a script that copies images to the Bitrise test directory.

    Replace the name_of_test_report with the name you set in the The name of the test input in the Export test results to Test Reports Step.

    TEST_RESULTS_DIR=$(find "$BITRISE_TEST_DEPLOY_DIR" -type d -name "<name_of_test_report>" -print -quit)
    cp ~/*.jpg $TEST_RESULTS_DIR

    このスクリプトは、イメージを次の特定のサブディレクトリに配置します。 BITRISE_TEST_DEPLOY_DIR テストレポートが保存されている場所。

  8. Add the Deploy to Bitrise.io Step to the end of your Workflow.

    You don't have to change the default input values.

  1. Generate a JUnit.xml file from your tests.

    The general file structure should look something like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <testsuites time="15.682687">
        <testsuite name="Tests.Registration" time="6.605871">
            <testcase name="testCase1" classname="Tests.Registration" time="2.113871" />
        </testsuite>
    </testsuites>
  2. Add a <properties> element to associate an attachment with a testcase.

    The name attribute of the element must be set with a value attachment_# where # is the ordered index of the attachment file, and the value is the filename. Bitrise will show attachments for any test with the attachment properties, but it's most common to only attach screenshots to failed tests. Mark a test as failed with a <failure> element.

    <testcase name="testCase1" classname="Tests.Registration" time="2.113871" />
      <failure message="Assertion error message" type="AssertionError">
        Call stack printed here
      </failure>
      <properties>
        <property name="attachment_1" value="pp1.jpg" />
        <property name="attachment_2" value="pp2.jpg" />
      </properties>            
    </testcase>
  3. を追加 custom-test-results-export JUnit XML ファイルを生成したら、Bitrise ワークフローにステップアップしてください。

    workflows:
      inline_attachment:
        steps:
        - generate-text-file:
            inputs:
            - file_name: junit.xml
            - file_content: "xml content with references to image files here"
        - custom-test-results-export:
  4. にテスト名を設定します test_name 入力。

    - custom-test-results-export@1:
        inputs:
        - test_name: example_tests
  5. JUnit XML ファイルへのパスを以下に設定します。 search_pattern 入力。

    - custom-test-results-export@1:
        inputs:
        - test_name: example_tests
        - search_pattern: junit.xml
  6. カスタムを追加 script ワークフローへのステップ

  7. の中に content 入力して、Bitrise テストディレクトリに画像をコピーするスクリプトを追加します。

    を交換してください name_of_test_report で設定した名前で test_name への入力 custom-test-results-export ステップ 1。

    - script:
        inputs:
        - content: |
            #!/usr/bin/env bash
            set -ex
            set -o pipefail
    
            TEST_RESULTS_DIR=$(find "$BITRISE_TEST_DEPLOY_DIR" -type d -name "example_tests" -print -quit)
            cp ~/*.jpg $TEST_RESULTS_DIR

    このスクリプトは、イメージを次の特定のサブディレクトリに配置します。 BITRISE_TEST_DEPLOY_DIR テストレポートが保存されている場所。

  8. を追加 deploy-to-bitrise-io ワークフローの最後まで進んでください。

    デフォルトの入力値を変更する必要はありません。設定 YAML ファイル内のワークフロー全体は次のようになります

    workflows:
      inline_attachment:
        steps:
        - generate-text-file@0:
            inputs:
            - file_name: junit.xml
            - file_content: "xml content with references to image files here"
        - custom-test-results-export@1:
            inputs:
            - test_name: example_tests
            - base_path: "."
            - search_pattern: junit.xml
        - script@1:
            inputs:
            - content: |
                #!/usr/bin/env bash
                set -ex
                set -o pipefail
    
                TEST_RESULTS_DIR=$(find "$BITRISE_TEST_DEPLOY_DIR" -type d -name "example_tests" -print -quit)
                cp ~/*.jpg $TEST_RESULTS_DIR
            title: Copy image files to test directory
        - deploy-to-bitrise-io@2: {}