メインコンテンツまでスキップ

JUnit XMLでの添付ファイルの参照

ファイルにテストケース名を付けられない場合は、代わりにJUnit XMLでファイルを参照します。

  1. テストから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>
  2. 添付ファイルを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>
  3. Export test results to Test Reports StepをBitrise Workflowに追加します。バージョンは1.1.0以降である必要があります。

  4. The name of the testインプットにテスト名を設定します。

  5. Test result search patternインプットにJUnit XMLファイルのパスを設定します。

  6. Workflowの最後にDeploy to Bitrise.io Stepを追加します。

    デフォルトのインプット値を変更する必要はありません。