BugreportCollector

public class BugreportCollector
extends Object implements ITestInvocationListener

java.lang.Object
   ↳ com.android.tradefed.result.BugreportCollector


構成可能なイベントが発生したときにバグレポートを収集し、各バグレポートの収集後に子で ITestInvocationListener.testLog を呼び出すパススルー ITestInvocationListener

動作:(FIXME: 完了)

  • テストケースが失敗した場合は、その都度キャプチャする
  • 各テストケースの後にキャプチャ
  • 各テストケースの失敗後にキャプチャする
  • キャプチャ

概要

ネストされたクラス

class BugreportCollector.Predicate

バグレポートをキャプチャするタイミングを説明する完全な述語。 

interface BugreportCollector.SubPredicate

 

フィールド

public static final BugreportCollector.Predicate AFTER_FAILED_TESTCASES

各テストケースの失敗後に発生する事前定義された述語

public static final BugreportCollector.Predicate AT_START

最初の呼び出しが開始されると起動する事前定義された述語

パブリック コンストラクタ

BugreportCollector(ITestInvocationListener listener, ITestDevice testDevice)

パブリック メソッド

void addPredicate(BugreportCollector.Predicate p)
void blockUntilIdle()

コレクタがバグレポートを収集しなくなるまでブロックします。

TestSummary getSummary()

InvocationListener が概要を返すことを許可します。

void invocationEnded(long elapsedTime)

呼び出しが終了したことを報告します(成功した場合も、エラー条件が原因で終了した場合も同様です)。

void invocationFailed(Throwable cause)

エラー条件のため、呼び出しが不完全であることを報告します。

void invocationStarted(IInvocationContext context)

テスト呼び出しの開始を報告します。

void setAsynchronous(boolean asynchronous)

バグレポート収集で、別のスレッドでバグレポートを収集する(asynchronous = true)か、バグレポートがキャプチャされるまで呼び出し元をブロックする(asynchronous = false)かを設定します。

void setDescriptiveName(String name)

バグレポートを記録する際に使用する説明的な名前を設定します。

void setDeviceWaitTime(int waitTime)

バグレポートの取得を試みる前に、デバイスがオンラインになるまで待機する時間(秒単位)を設定します。

void testAssumptionFailure(TestDescription test, String trace)

アトミック テストが、false の条件を想定していることを示すフラグを設定したときに呼び出されます。

void testEnded(TestDescription test, HashMap<String, MetricMeasurement.Metric> testMetrics)

個々のテストケースの実行終了を報告します。

void testFailed(TestDescription test, String trace)

個々のテストケースの失敗を報告します。

void testIgnored(TestDescription test)

テストが実行されない場合に呼び出されます。通常、テストメソッドに org.junit.Ignore のアノテーションが付いていることが原因です。

void testLog(String dataName, LogDataType dataType, InputStreamSource dataStream)

テスト呼び出しから関連するログまたはデバッグデータを提供します。

void testRunEnded(long elapsedTime, HashMap<String, MetricMeasurement.Metric> runMetrics)

テスト実行の終了を報告します。

void testRunFailed(String errorMessage)

致命的なエラーのため、レポートのテスト実行を完了できませんでした。

void testRunStarted(String runName, int testCount)

テスト実行の開始を報告します。

void testRunStopped(long elapsedTime)

ユーザーのリクエストにより、レポートのテスト実行が完了前に停止しました。

void testStarted(TestDescription test)

個々のテストケースの開始を報告します。

フィールド

AFTER_FAILED_TESTCASES

public static final BugreportCollector.Predicate AFTER_FAILED_TESTCASES

各テストケースの失敗後に起動する事前定義された述語

AT_START

public static final BugreportCollector.Predicate AT_START

最初の呼び出しが開始されると起動する事前定義された述語

パブリック コンストラクタ

BugreportCollector

public BugreportCollector (ITestInvocationListener listener, 
                ITestDevice testDevice)

パラメータ
listener ITestInvocationListener

testDevice ITestDevice

パブリック メソッド

addPredicate

public void addPredicate (BugreportCollector.Predicate p)

パラメータ
p BugreportCollector.Predicate

blockUntilIdle

public void blockUntilIdle ()

コレクタがバグレポートを収集しなくなるまでブロックします。コレクタがバグレポートをアクティブに収集していない場合は、すぐに戻る

getSummary

public TestSummary getSummary ()

InvocationListener が概要を返すことを許可します。

戻り値
TestSummary 実行を要約する TestSummary、または null

invocationEnded

public void invocationEnded (long elapsedTime)

呼び出しが終了したことを報告します(成功した場合も、エラー条件が原因で終了した場合も同様です)。

TradeFederation フレームワークによって自動的に呼び出されます。

パラメータ
elapsedTime long: 呼び出しの経過時間(ミリ秒単位)

invocationFailed

public void invocationFailed (Throwable cause)

エラー条件のため、呼び出しが不完全であることを報告します。

TradeFederation フレームワークによって自動的に呼び出されます。

パラメータ
cause Throwable: 失敗の Throwable 原因

invocationStarted

public void invocationStarted (IInvocationContext context)

テスト呼び出しの開始を報告します。

TradeFederation フレームワークによって自動的に呼び出されます。複数のデバイスのレポートをサポートするには、レポート作成者がこのメソッドをオーバーライドする必要があります。

パラメータ
context IInvocationContext: 呼び出しに関する情報

setAsynchronous

public void setAsynchronous (boolean asynchronous)

バグレポート収集で、別のスレッドでバグレポートを収集する(asynchronous = true)か、バグレポートがキャプチャされるまで呼び出し元をブロックする(asynchronous = false)かを設定します。

パラメータ
asynchronous boolean

setDescriptiveName

public void setDescriptiveName (String name)

バグレポートを記録する際に使用する説明的な名前を設定します。null の場合、BugreportCollector は、バグレポートの収集を引き起こしたイベントの名前をシリアル化するデフォルトの動作に戻ります。

パラメータ
name String

setDeviceWaitTime

public void setDeviceWaitTime (int waitTime)

バグレポートの取得を試みる前にデバイスがオンラインになるまで待機する時間(秒単位)を設定します。負の値の場合、チェックは実行されません。このチェック中に検出された DeviceNotAvailableException はログに記録され、無視されます。

パラメータ
waitTime int

testAssumptionFailure

public void testAssumptionFailure (TestDescription test, 
                String trace)

アトミック テストが、false の条件を想定していることを示すフラグを設定したときに呼び出されます

パラメータ
test TestDescription: テストを識別します

trace String: 失敗のスタック トレース

testEnded

public void testEnded (TestDescription test, 
                HashMap<String, MetricMeasurement.Metric> testMetrics)

個々のテストケースの実行終了を報告します。

testFailed(TestDescription, FailureDescription) が呼び出されなかった場合、このテストは合格です。テストケースの実行中に生成された Key-Value 指標も返します。

パラメータ
test TestDescription: テストを識別します

testMetrics HashMap: 出力された指標の Map

testFailed

public void testFailed (TestDescription test, 
                String trace)

個々のテストケースの失敗を報告します。

testStarted と testEnded の間に呼び出されます。

パラメータ
test TestDescription: テストを識別します

trace String: 失敗のスタック トレース

testIgnored

public void testIgnored (TestDescription test)

テストが実行されない場合に呼び出されます。通常、テストメソッドに org.junit.Ignore のアノテーションが付いていることが原因です。

パラメータ
test TestDescription: テストを識別します

testLog

public void testLog (String dataName, 
                LogDataType dataType, 
                InputStreamSource dataStream)

テスト呼び出しに関連するログデータまたはデバッグデータを提供します。

ERROR(ITestInvocationListener.invocationFailed(Throwable)/ITestInvocationListener#invocationFailed(java.lang.Throwable) ITestInvocationListener.invocationFailed(Throwable)) または ERROR(/ITestInvocationListener#invocationEnded(long)) の前に呼び出す必要があります。

TradeFederation フレームワークは、このメソッドを自動的に呼び出し、ホストログと、該当する場合はデバイスの logcat を提供します。

パラメータ
dataName String: データの String 説明的な名前(例: device_logcat)。注: dataName は呼び出しごとに一意でない場合があります。つまり、実装者は同じ dataName での複数の呼び出しを処理できる必要があります。

dataType LogDataType: データの LogDataType

dataStream InputStreamSource: データの InputStreamSource。実装者は、createInputStream を呼び出してデータの読み取りを開始し、完了したら結果の InputStream を必ず閉じます。呼び出し元は、testLog メソッドが完了するまで、データのソースが存在し、アクセス可能であることを確認する必要があります。

testRunEnded

public void testRunEnded (long elapsedTime, 
                HashMap<String, MetricMeasurement.Metric> runMetrics)

テスト実行の終了を報告します。FIXME: 型が異なる Map<> インターフェースを 2 つ持つことはできないため、ここでは HashMap を使用する必要があります。

パラメータ
elapsedTime long: デバイスが報告した経過時間(ミリ秒単位)

runMetrics HashMap: Metric を使用したテスト実行の最後にレポートされる Key-Value ペア。

testRunFailed

public void testRunFailed (String errorMessage)

致命的なエラーのため、レポートのテスト実行を完了できませんでした。

パラメータ
errorMessage String: 実行の失敗理由を説明する String

testRunStarted

public void testRunStarted (String runName, 
                int testCount)

テスト実行の開始を報告します。

パラメータ
runName String: テスト実行名

testCount int: テスト実行のテストの合計数

testRunStopped

public void testRunStopped (long elapsedTime)

ユーザーのリクエストにより、レポートのテスト実行が完了前に停止しました。

TODO: 現在使用されていません。削除することを検討してください

パラメータ
elapsedTime long: デバイスが報告した経過時間(ミリ秒単位)

testStarted

public void testStarted (TestDescription test)

個々のテストケースの開始を報告します。古いインターフェース。可能な限り testStarted(TestDescription) を使用する必要があります。

パラメータ
test TestDescription: テストを識別します