JUnit XMLでの添付ファイルの参照
ファイルにテストケース名を付けられない場合は、代わりにJUnit XMLでファイルを参照します。
- Workflow Editor
- Configuration YAML
-
テストから
JUnit.xmlファイルを生成します。ファイル構造は、おおよそ次のようになります。
<?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> -
添付ファイルを
testcaseに関連付けるため、<properties>要素を追加します。要素の
name属性には、attachment_#(#は添付ファイルの順序インデックス)という値を設定し、値にはファイル名を指定します。Bitriseは、添付ファイルのプロパティを持つすべてのテストの添付ファイルを表示しますが、通常は失敗したテストにのみスクリーンショットを添付します。テストを失敗としてマークするには、<failure>要素を使用します。<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> -
Export test results to Test Reports StepをBitrise Workflowに追加します。バージョンは1.1.0以降である必要があります。
-
The name of the testインプットにテスト名を設定します。
-
Test result search patternインプットにJUnit XMLファイルのパスを設定します。
-
Workflowの最後にDeploy to Bitrise.io Stepを追加します。
デフォルトのインプット値を変更する必要はありません。
-
テストから
JUnit.xmlファイルを生成します。ファイル構造は、おおよそ次のようになります。
<?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> -
添付ファイルを
testcaseに関連付けるため、<properties>要素を追加します。要素の
name属性には、attachment_#(#は添付ファイルの順序インデックス)という値を設定し、値にはファイル名を指定します。Bitriseは、添付ファイルのプロパティを持つすべてのテストの添付ファイルを表示しますが、通常は失敗したテストにのみスクリーンショットを添付します。テストを失敗としてマークするには、<failure>要素を使用します。<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> -
JUnit XMLファイルを生成した後、
custom-test-results-exportStepをBitrise Workflowに追加します。バージョンは1.1.0以降である必要があります。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 -
search_patternインプットにJUnit XMLファイルのパスを設定します。- custom-test-results-export@1:inputs:- test_name: example_tests- search_pattern: junit.xml -
Workflowの最後に
deploy-to-bitrise-ioStepを追加します。デフォルトのインプット値を変更する必要はありません。configuration YAMLファイル内の完全なWorkflowは、次のようになります。
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 bashset -exset -o pipefailTEST_RESULTS_DIR=$(find "$BITRISE_TEST_DEPLOY_DIR" -type d -name "example_tests" -print -quit)cp ~/*.jpg $TEST_RESULTS_DIRtitle: Copy image files to test directory- deploy-to-bitrise-io@2: {}