テスト結果の展開と表示
CI ビルド後、テスト結果を 1 か所で確認できます。ワークフローに複数のテストステップがあっても、すべてのテストはビルドページに表示されます。私たちの目標は、Bitrise上でアクセス可能で実用的なテスト結果が得られるようにすることです。これにより、テスト失敗からの回復までの時間を短縮し、全体的な開発者体験を向上させることができます
テスト結果のデプロイ
最小限の設定でテスト結果をビルドページにデプロイします。要件はセットアップによって異なります。
-
Bitriseの公式テストステップを使ってテストを実行する
-
他のステップを使用してテストを実行する
Bitriseの公式テストステップの結果をデプロイする
サポートされているテスト手順は次のとおりです。
-
アンドロイドユニットテスト: Android 単体テストの実行。
-
アンドロイドインストルメントテスト: Android アプリの計測済みテストの実行。
-
iOS 用 Xcode テスト: iOS アプリの単体テストと UI テストの実行。
-
iOS デバイステスト: iOSのデバイステスト。
-
Android 向け仮想デバイステスト: Androidのデバイステスト。
-
フラッターテスト: Flutter アプリのテスト。
これらのステップのいずれかを使用する場合は、次のものが揃っていることを確認してください Bitrise.io にデプロイしてください ワークフローにステップイン。Bitrise はテスト結果を自動的にビルドページにデプロイします
アタッチメントとフレークテスト
テストで添付ファイルが生成されたり、Bitriseに不安定なテストを表示させたい場合、 Bitrise.io にデプロイしてください ステップはバージョン 2.19.1 以降である必要があります。
他のステップの結果のデプロイ
他のステップを使用してテストを実行する場合 (たとえば、 スクリプト 完全にカスタム化されたテストソリューションの手順) については、追加の設定が必要です。
-
テストを実行するステップをワークフローに追加します。
-
を追加 テスト結果をテストレポートアドオンにエクスポートする ワークフローへのステップ。
-
ステップを設定します。 テスト結果をテストレポートアドオンにエクスポートするステップを使用する。
-
お持ちであることを確認してください Bitrise.io にデプロイしてください ワークフローにステップイン。
アタッチメントとフレークテスト
テストで添付ファイルが生成されたり、Bitriseに不安定なテストを表示させたい場合、 Bitrise.io にデプロイしてください ステップはバージョン 2.19.1 以降である必要があります。
テスト結果の表示
リッチ HTML レポート
使用する場合 リッチ HTML テストレポート、それらはまだにあります アーティファクト タブ。
結果を表示するには、ビルドページを開いて、 テスト タブ。テストはステータスに応じてさまざまなタブに分類されます。
-
失敗
-
合格しました
-
スキップされました
-
エラー
-
薄片状
デフォルトでは、Bitriseは失敗したテストのリストを表示します。これらの各カテゴリでテスト実行の詳細を表示できます
任意のテストをクリックして、テスト期間、出力、およびテストで生成された添付ファイルの詳細を確認します。
で不安定なテストを見ることができます 薄片状 タブ。不安定なテストとは、コードを変更しなくても失敗することもあれば成功することもあるテストです。テストが失敗し、その後も成功した場合 自動再試行、Bitriseはテストを不安定とマークし、以下で確認できます フレーク状 タブ。また、テストを再試行するたびの詳細と添付ファイルも表示されます

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
-
Generate a
JUnit.xmlfile 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> -
Add a
<properties>element to associate an attachment with atestcase.The
nameattribute of the element must be set with a valueattachment_#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> -
Add the Export test results to Test Reports Step to your Bitrise Workflow.
-
Set a test name in the The name of the test input.
-
Set the path to your JUnit XML file in the Test result search pattern input.
-
Add a custom Script Step to your Workflow
-
In the Script content input, add a script that copies images to the Bitrise test directory.
Replace the
name_of_test_reportwith 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テストレポートが保存されている場所。 -
Add the Deploy to Bitrise.io Step to the end of your Workflow.
You don't have to change the default input values.
-
Generate a
JUnit.xmlfile 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> -
Add a
<properties>element to associate an attachment with atestcase.The
nameattribute of the element must be set with a valueattachment_#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> -
を追加
custom-test-results-exportJUnit 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: -
にテスト名を設定します
test_name入力。- custom-test-results-export@1: inputs: - test_name: example_tests -
JUnit XML ファイルへのパスを以下に設定します。
search_pattern入力。- custom-test-results-export@1: inputs: - test_name: example_tests - search_pattern: junit.xml -
カスタムを追加
scriptワークフローへのステップ -
の中に
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テストレポートが保存されている場所。 -
を追加
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: {}