2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
結果レポーターを作成する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
このページでは、新しい結果レポーターを実装してテスト用に設定する基本的な方法について説明します。
コア インターフェース
Tradefed で新しい結果レポーターを定義するには、クラスで ITestInvocationListener
インターフェースを実装し、呼び出しのさまざまな段階を受け取って処理できるようにします。
invocationStarted
invocationEnded
invocationFailed
結果レポーターは、各テスト実行のさまざまな段階も処理します。
testRunStarted
testStarted
testFailed
または testIgnored
testEnded
testRunFailed
testRunEnded
これらすべてのイベントを考慮すると、結果レポーターには主に次の 2 つのタイプがあります。
- 最終の完全な結果の報告のみを行うもの。
- 部分的な結果に対応するもの。
最終の完全な結果を報告する結果レポーター
このタイプは、結果を受け取る外部サービスとやり取りする場合に最も一般的です。レポーターは単純に結果を受け取って蓄積し、そのすべてを invocationEnded
で結果エンドポイントに送信します。
このようなレポーターでは、ベース インターフェースではなく CollectingTestListener
を拡張して、invocationEnded
まで結果の再実装、保存、格納を行わないようにすることをおすすめします。
部分的な結果を報告する結果レポーター
このタイプは通常、結果を受け取ってすぐ他の場所にプッシュする場合に、結果のストリーミング アプローチに使用されます。たとえば結果をコンソールに記録するレポーターは、このタイプです。
このタイプは、イベントで必要な処理のタイプに応じて使用するため、通常はベース インターフェースを実装することをおすすめします。
XML 構成
オブジェクト タグは result_reporter
です。次に例を示します。
<result_reporter class="com.android.tradefed.result.ConsoleResultReporter">
<option name="suppress-passed-tests" value="true"/>
</result_reporter>
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-03-26 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-03-26 UTC。"],[],[],null,["# Create a result reporter\n\nThis page describes the basics of how to implement a new result reporter and\nconfigure it for a test.\n\nCore interface\n--------------\n\nIn order to define a new result reporter in Tradefed, a class must implement\nthe\n[`ITestInvocationListener`](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/invocation_interfaces/com/android/tradefed/result/ITestInvocationListener.java)\ninterface that allows receiving and handling different stages of the\ninvocation:\n\n- `invocationStarted`\n- `invocationEnded`\n- `invocationFailed`\n\nResult reporters also handle the different stages of each test run:\n\n- `testRunStarted`\n- `testStarted`\n- `testFailed` or `testIgnored`\n- `testEnded`\n- `testRunFailed`\n- `testRunEnded`\n\nGiven all these events, there are two main types of result reporters, those that:\n\n- Care only about reporting the final complete results.\n- Take action on partial results.\n\n### Result reporter that reports final complete results\n\nThis type is the most common case when it comes to interacting with an external\nservice that receives the results. The reporter simply receives and accumulates\nthe results and then sends them all on `invocationEnded` to the result end-point.\n\nWe recommend that those reporters extend `CollectingTestListener` instead\nof the base interface in order to avoid reimplementing saving and storing the\nresults until `invocationEnded`.\n\n### Result reporter that reports partial results\n\nThis type is usually used for a streaming approach of the results, when results\nare received and pushed to some other places right away. For example, a reporter\nthat logs the results to the console would be of this type.\n\nThis type is specific to which type of handling is required on the events,\nso implementing the base interface is usually the recommended way.\n\n### XML configuration\n\nThe object tag is `result_reporter`. For example: \n\n \u003cresult_reporter class=\"com.android.tradefed.result.ConsoleResultReporter\"\u003e\n \u003coption name=\"suppress-passed-tests\" value=\"true\"/\u003e\n \u003c/result_reporter\u003e"]]