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, 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, 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, 
                 testMetrics)

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

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

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

testMetrics : 出力された指標の ERROR(/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)) または ERROR(/ITestInvocationListener#invocationEnded(long)) の前に呼び出す必要があります。

TradeFederation フレームワークは、このメソッドを自動的に呼び出し、ホストログと、必要に応じてデバイスの logcat を提供します。

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

dataType LogDataType: データの LogDataType

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

testRunEnded

public void testRunEnded (long elapsedTime, 
                 runMetrics)

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

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

runMetrics : テスト実行の終了時に報告される 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(com.android.tradefed.result.TestDescription) を使用してください。

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