CollectingTestListener
public class CollectingTestListener
extends Object
implements ITestInvocationListener , ILogSaverListener , IDisableable
java.lang.Object | |
↳ | com.android.tradefed.result.CollectingTestListener |
すべてのテスト結果を収集するITestInvocationListener
。
このオブジェクトで使用されるデータ構造はスレッド セーフですが、 ITestInvocationListener
コールバックは正しい順序で呼び出す必要があります。
まとめ
パブリック コンストラクター | |
---|---|
CollectingTestListener () |
公開メソッド | |
---|---|
IBuildInfo | getBuildInfo () このメソッドは非推奨です。 |
TestRunResult | getCurrentRunResults () 現在のテスト実行の結果を取得します。 |
int | getExpectedTests () 予想されるテスト カウントの数を返します。 |
IInvocationContext | getInvocationContext () |
getMergedTestRunResults () 異なる試行にわたるすべての実行のマージされた結果のコレクションを返します。 | |
IInvocationContext | getModuleContextForRunResult (String testRunName) 結果に関連付けられたモジュールの |
MultiMap <String, LogFile > | getModuleLogFiles () モジュールに関連付けられたすべてのログ ファイルを含むマップのコピーを返します。 |
MultiMap <String, LogFile > | getNonAssociatedLogFiles () テスト実行またはモジュールに関連付けられていないすべてのログ ファイルを含むマップのコピーを返します。 |
int | getNumAllFailedTestRuns () 失敗状態のテスト実行の総数を返します |
int | getNumAllFailedTests () 失敗状態のテストの総数を返します (失敗のみで、仮定の失敗はカウントされません)。 |
int | getNumTestsInState (TestResult.TestStatus status) この実行で指定された状態にあるテストの数を返します。 |
int | getNumTotalTests () すべての実行で完了したテストの総数を返します。 |
IBuildInfo | getPrimaryBuildInfo () |
getRunResults () このメソッドは非推奨です。 | |
TestRunResult | getTestRunAtAttempt (String testRunName, int attempt) 1 回の試行に対して |
int | getTestRunAttemptCount (String testRunName) 指定されたテスト実行名の試行回数を返します。 |
getTestRunAttempts (String testRunName) 特定のテスト実行の | |
getTestRunForAttempts (int attempt) 特定の試行のすべての結果を取得します。 | |
getTestRunNames () すべてのテスト実行のすべての名前を返します。 | |
boolean | hasFailedTests () 呼び出しに失敗したテストまたは仮定に失敗したテストがあったかどうかを返します。 |
boolean | hasTestRunResultsForName (String testRunName) 指定されたテスト実行名に結果があるかどうかを返します。 |
void | invocationEnded (long elapsedTime) 呼び出しが正常に終了したか、何らかのエラー状態により終了したことを報告します。 |
void | invocationFailed (Throwable cause) 何らかのエラー状態による不完全な呼び出しを報告します。 |
void | invocationStarted ( IInvocationContext context) テスト呼び出しの開始を報告します。 |
boolean | isDisabled () オブジェクト全体が無効になっている場合は True を返します (セットアップとティアダウンの両方をスキップします)。 |
void | logAssociation (String dataName, LogFile logFile) 場合によっては、ログをテスト ケースと強く関連付ける必要がありますが、直接 |
void | setBuildInfo ( IBuildInfo buildInfo) このメソッドは非推奨です。テストにはもう必要ありません。 |
void | setDisable (boolean isDisabled) オブジェクトを無効にするかどうかを設定します。 |
void | setMergeStrategy ( MergeStrategy strategy) 結果をマージするときに使用する |
void | testAssumptionFailure ( TestDescription test, String trace) アトミック テストが false の条件を想定していることを示すフラグを立てたときに呼び出されます |
void | testAssumptionFailure ( TestDescription test, FailureDescription failure) アトミック テストが false の条件を想定していることを示すフラグを立てたときに呼び出されます |
void | testEnded ( TestDescription test, long endTime, testMetrics) testEnded ( TestDescription test, long endTime, testMetrics) |
void | testEnded ( TestDescription test, testMetrics) testEnded ( TestDescription test, testMetrics) 個々のテスト ケースの実行終了を報告します。 |
void | testFailed ( TestDescription test, FailureDescription failure) 個々のテスト ケースの失敗を報告します。 |
void | testFailed ( TestDescription test, String trace) 個々のテスト ケースの失敗を報告します。 |
void | testIgnored ( TestDescription test) 通常、テストメソッドに org.junit.Ignore の注釈が付けられているため、テストが実行されない場合に呼び出されます。 |
void | testModuleEnded () モジュール実行の終了を報告します。 |
void | testModuleStarted ( IInvocationContext moduleContext) 実行中のモジュールの開始を報告します。 |
void | testRunEnded (long elapsedTime, runMetrics) testRunEnded (long elapsedTime, runMetrics) テスト実行の終了を報告します。 |
void | testRunFailed ( FailureDescription failure) |
void | testRunFailed (String errorMessage) 致命的なエラーのため、レポートのテスト実行を完了できませんでした。 |
void | testRunStarted (String name, int numTests, int attemptNumber) テスト実行の開始を報告します。 |
void | testRunStarted (String name, int numTests) テスト実行の開始を報告します。 |
void | testRunStarted (String name, int numTests, int attemptNumber, long startTime) テスト実行の開始を報告します。 |
void | testRunStopped (long elapsedTime) レポートのテスト実行は、ユーザーの要求により完了前に停止しました。 |
void | testStarted ( TestDescription test, long startTime) |
void | testStarted ( TestDescription test) 個々のテスト ケースの開始を報告します。 |
保護されたメソッド | |
---|---|
final void | clearModuleLogFiles () モジュールファイルのクリーニングを許可して、長時間持ち歩くことを避けます。 |
final void | clearResultsForName (String testRunName) 特定の実行名の結果をクリアできます。 |
void | setIsAggregrateMetrics (boolean aggregate) 「集計メトリクス」オプションを切り替えます |
パブリック コンストラクター
CollectingTestListener
public CollectingTestListener ()
公開メソッド
getBuildInfo
public IBuildInfo getBuildInfo ()
このメソッドは非推奨です。
getInvocationContext()
からのIBuildInfo
に依存します。
ビルド情報を返します。
戻り値 | |
---|---|
IBuildInfo |
getCurrentRunResults
public TestRunResult getCurrentRunResults ()
現在のテスト実行の結果を取得します。
結果が完全ではない可能性があることに注意してください。結果を処理する前に、必要に応じてTestRunResult.isRunComplete()
および/または (@link TestRunResult#isRunFailure()} の値をテストすることをお勧めします。
戻り値 | |
---|---|
TestRunResult | 最後のテスト実行中に収集されたデータを表すTestRunResult |
getExpectedTests
public int getExpectedTests ()
予想されるテスト カウントの数を返します。一部のテストが実行されなかった場合、 getNumTotalTests()
とは異なる可能性があります。
戻り値 | |
---|---|
int |
getInvocationContext
public IInvocationContext getInvocationContext ()
invocationStarted(com.android.tradefed.invoker.IInvocationContext)
を介して報告された呼び出しコンテキストを返します
戻り値 | |
---|---|
IInvocationContext |
getMergedTestRunResults
publicgetMergedTestRunResults ()
異なる試行にわたるすべての実行のマージされた結果のコレクションを返します。
複数の結果がある場合、各テストの実行がマージされ、最新のテスト結果が以前の実行のテスト結果を上書きします。テスト実行は試行番号順に並べられます。
同じ試行のメトリクスは、 aggregate-metrics
によって設定された設定に基づいてマージされます。最終的なメトリックは、最後の試行のメトリックになります。
戻り値 | |
---|---|
getModuleContextForRunResult
public IInvocationContext getModuleContextForRunResult (String testRunName)
結果に関連付けられたモジュールのIInvocationContext
を返します。
パラメーター | |
---|---|
testRunName | String : { testRunStarted(String, int) によって指定された名前。 |
戻り値 | |
---|---|
IInvocationContext | その名前の結果がない場合、特定のテスト実行名のモジュールのIInvocationContext はnull 。 |
getModuleLogFiles
public MultiMap<String, LogFile> getModuleLogFiles ()
モジュールに関連付けられたすべてのログ ファイルを含むマップのコピーを返します。
戻り値 | |
---|---|
MultiMap <String, LogFile > |
getNonAssociatedLogFiles
public MultiMap<String, LogFile> getNonAssociatedLogFiles ()
テスト実行またはモジュールに関連付けられていないすべてのログ ファイルを含むマップのコピーを返します。
戻り値 | |
---|---|
MultiMap <String, LogFile > |
getNumAllFailedTestRuns
public int getNumAllFailedTestRuns ()
失敗状態のテスト実行の総数を返します
戻り値 | |
---|---|
int |
getNumAllFailedTests
public int getNumAllFailedTests ()
失敗状態のテストの総数を返します (失敗のみで、仮定の失敗はカウントされません)。
戻り値 | |
---|---|
int |
getNumTestsInState
public int getNumTestsInState (TestResult.TestStatus status)
この実行で指定された状態にあるテストの数を返します。
パラメーター | |
---|---|
status | TestResult.TestStatus |
戻り値 | |
---|---|
int |
getNumTotalTests
public int getNumTotalTests ()
すべての実行で完了したテストの総数を返します。
戻り値 | |
---|---|
int |
getPrimaryBuildInfo
public IBuildInfo getPrimaryBuildInfo ()
invocationStarted(com.android.tradefed.invoker.IInvocationContext)
を介して報告されたプライマリ ビルド情報を返します。プライマリ ビルドは、実行中の構成の最初のビルド プロバイダーによって返されるビルドです。コンテキストがない (テスト ケースへのビルドがない) 場合は null を返します。
戻り値 | |
---|---|
IBuildInfo |
getRunResults
publicgetRunResults ()
このメソッドは非推奨です。
getMergedTestRunResults()
を使用する
すべてのテスト実行の結果を返します。
戻り値 | |
---|---|
getTestRunAtAttempt
public TestRunResult getTestRunAtAttempt (String testRunName, int attempt)
1 回の試行に対してTestRunResult
を返します。
パラメーター | |
---|---|
testRunName | String : { testRunStarted(String, int) によって指定された名前。 |
attempt | int : 試行 ID。 |
戻り値 | |
---|---|
TestRunResult | 指定された名前と試行 ID のTestRunResult 、または存在しない場合はnull 。 |
getTestRunAttemptCount
public int getTestRunAttemptCount (String testRunName)
指定されたテスト実行名の試行回数を返します。
パラメーター | |
---|---|
testRunName | String : { testRunStarted(String, int) によって指定された名前。 |
戻り値 | |
---|---|
int |
getTestRunAttempts
publicgetTestRunAttempts (String testRunName)
特定のテスト実行のTestRunResult
に対するすべての試行を取得します。
パラメーター | |
---|---|
testRunName | String : { testRunStarted(String, int) によって指定された名前。 |
戻り値 | |
---|---|
試行順に並べられた、特定のテスト実行のすべてのTestRunResult 。 |
getTestRunForAttempts
publicgetTestRunForAttempts (int attempt)
特定の試行のすべての結果を取得します。
パラメーター | |
---|---|
attempt | int : 結果が必要な試行。 |
戻り値 | |
---|---|
特定の試行に対するすべてのTestRunResult 。 |
getTestRunNames
publicgetTestRunNames ()
すべてのテスト実行のすべての名前を返します。
これらのテスト実行は、試行を変えて複数回実行された可能性があります。
戻り値 | |
---|---|
hasFailedTests
public boolean hasFailedTests ()
呼び出しに失敗したテストまたは仮定に失敗したテストがあったかどうかを返します。
戻り値 | |
---|---|
boolean |
hasTestRunResultsForName
public boolean hasTestRunResultsForName (String testRunName)
指定されたテスト実行名に結果があるかどうかを返します。
パラメーター | |
---|---|
testRunName | String : { testRunStarted(String, int) によって指定された名前。 |
戻り値 | |
---|---|
boolean |
呼び出し終了
public void invocationEnded (long elapsedTime)
呼び出しが正常に終了したか、何らかのエラー状態により終了したことを報告します。
TradeFederation フレームワークによって自動的に呼び出されます。パラメーター | |
---|---|
elapsedTime | long : 呼び出しの経過時間 (ミリ秒) |
呼び出し失敗
public void invocationFailed (Throwable cause)
何らかのエラー状態による不完全な呼び出しを報告します。
TradeFederation フレームワークによって自動的に呼び出されます。パラメーター | |
---|---|
cause | Throwable : ERROR(/Throwable) 失敗の原因 |
呼び出し開始
public void invocationStarted (IInvocationContext context)
テスト呼び出しの開始を報告します。
TradeFederation フレームワークによって自動的に呼び出されます。レポーターは、複数のデバイス レポートをサポートするために、このメソッドをオーバーライドする必要があります。
パラメーター | |
---|---|
context | IInvocationContext : 呼び出しに関する情報 |
無効になっています
public boolean isDisabled ()
オブジェクト全体が無効になっている場合は True を返します (セットアップとティアダウンの両方をスキップします)。それ以外の場合は偽。
戻り値 | |
---|---|
boolean |
ログ関連付け
public void logAssociation (String dataName, LogFile logFile)
場合によっては、ログをテスト ケースと強く関連付ける必要がありますが、直接testLogSaved(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.LogFile)
コールバックはできません。したがって、このコールバックにより、強い関連付けを明示的に提供できます。
パラメーター | |
---|---|
dataName | String : データの名前 |
logFile | LogFile : 以前にログに記録され、テスト ケースに関連付ける必要があるLogFile 。 |
setBuildInfo
public void setBuildInfo (IBuildInfo buildInfo)
このメソッドは非推奨です。
テストにはもう必要ありません。
ビルド情報を設定します。テスト用にのみ使用してください。
パラメーター | |
---|---|
buildInfo | IBuildInfo |
setDisable
public void setDisable (boolean isDisabled)
オブジェクトを無効にするかどうかを設定します。無効にすると、セットアップと破棄の両方の手順をスキップする必要があります。デフォルトのコンストラクターでオブジェクトをデフォルトで無効にするために使用できます。
パラメーター | |
---|---|
isDisabled | boolean : オブジェクトが置かれるべき状態。 |
setMergeStrategy
public void setMergeStrategy (MergeStrategy strategy)
結果をマージするときに使用するMergeStrategy
を設定します。
パラメーター | |
---|---|
strategy | MergeStrategy |
testAssumptionFailure
public void testAssumptionFailure (TestDescription test, String trace)
アトミック テストが false の条件を想定していることを示すフラグを立てたときに呼び出されます
パラメーター | |
---|---|
test | TestDescription : テストを識別します |
trace | String : 失敗のスタック トレース |
testAssumptionFailure
public void testAssumptionFailure (TestDescription test, FailureDescription failure)
アトミック テストが false の条件を想定していることを示すフラグを立てたときに呼び出されます
パラメーター | |
---|---|
test | TestDescription : テストを識別します |
failure | FailureDescription : 失敗とそのコンテキストを説明するFailureDescription 。 |
テスト終了
public void testEnded (TestDescription test, long endTime,testMetrics)
ERROR(/#testEnded(com.android.tradefed.result.TestDescription,Map))
の代わりに、終了時間を直接指定できます。正確な測定のためにtestStarted(com.android.tradefed.result.TestDescription, long)
と組み合わせます。
パラメーター | |
---|---|
test | TestDescription : テストを識別します |
endTime | long : ERROR(/System#currentTimeMillis()) を介して測定された、テストが終了した時間 |
testMetrics | ERROR(/Map) |
テスト終了
public void testEnded (TestDescription test,testMetrics)
個々のテスト ケースの実行終了を報告します。
testFailed(TestDescription, FailureDescription)
が呼び出されなかった場合、このテストは成功しました。また、テスト ケースの実行中に発行された可能性のあるキー/値メトリックも返します。
パラメーター | |
---|---|
test | TestDescription : テストを識別します |
testMetrics | ERROR(/Map) |
テスト失敗
public void testFailed (TestDescription test, FailureDescription failure)
個々のテスト ケースの失敗を報告します。
testStarted と testEnded の間で呼び出されます。
パラメーター | |
---|---|
test | TestDescription : テストを識別します |
failure | FailureDescription : 失敗とそのコンテキストを説明するFailureDescription 。 |
テスト失敗
public void testFailed (TestDescription test, String trace)
個々のテスト ケースの失敗を報告します。
testStarted と testEnded の間で呼び出されます。
パラメーター | |
---|---|
test | TestDescription : テストを識別します |
trace | String : 失敗のスタック トレース |
テスト無視
public void testIgnored (TestDescription test)
通常、テストメソッドに org.junit.Ignore の注釈が付けられているため、テストが実行されない場合に呼び出されます。
パラメーター | |
---|---|
test | TestDescription : テストを識別します |
testModuleEnded
public void testModuleEnded ()
モジュール実行の終了を報告します。
testModuleStarted
public void testModuleStarted (IInvocationContext moduleContext)
実行中のモジュールの開始を報告します。このコールバックはtestModuleEnded()
に関連付けられており、シーケンスではオプションです。モジュールを使用する実行中にのみ使用されます: スイートベースのランナー。
パラメーター | |
---|---|
moduleContext | IInvocationContext : モジュールのIInvocationContext 。 |
testRunEnded
public void testRunEnded (long elapsedTime,runMetrics)
テスト実行の終了を報告します。 FIXME: タイプの異なる 2 つの Map<> インターフェイスを持つことはできないため、ここでは HashMap を使用する必要があります。
パラメーター | |
---|---|
elapsedTime | long : デバイスが報告した経過時間 (ミリ秒) |
runMetrics | Metric でのテスト実行の最後に報告されるキーと値のペア。 |
testRunFailed
public void testRunFailed (FailureDescription failure)
FailureDescription
で説明されているエラーのため、レポートのテスト実行を完了できませんでした。
パラメーター | |
---|---|
failure | FailureDescription : 失敗とそのコンテキストを説明するFailureDescription 。 |
testRunFailed
public void testRunFailed (String errorMessage)
致命的なエラーのため、レポートのテスト実行を完了できませんでした。
パラメーター | |
---|---|
errorMessage | String : 実行失敗の理由を説明するERROR(/String) 。 |
testRunStarted
public void testRunStarted (String name, int numTests, int attemptNumber)
テスト実行の開始を報告します。
パラメーター | |
---|---|
name | String : テスト実行名 |
numTests | int : テスト実行中のテストの総数 |
attemptNumber | int : 複数回実行される同じ runName の異なる試行を識別する順序番号。 AttemptNumber のインデックスは 0 であり、新しい実行が発生するたびに増加する必要があります。たとえば、テストは詳細に 3 回再試行されます。同じ runName で合計 4 回実行する必要があり、attemptNumber は 0 から 3 です。 |
testRunStarted
public void testRunStarted (String name, int numTests)
テスト実行の開始を報告します。
パラメーター | |
---|---|
name | String : テスト実行名 |
numTests | int : テスト実行中のテストの総数 |
testRunStarted
public void testRunStarted (String name, int numTests, int attemptNumber, long startTime)
テスト実行の開始を報告します。
パラメーター | |
---|---|
name | String : テスト実行名 |
numTests | int : テスト実行中のテストの総数 |
attemptNumber | int : 複数回実行される同じ runName の異なる試行を識別する順序番号。 AttemptNumber のインデックスは 0 であり、新しい実行が発生するたびに増加する必要があります。たとえば、テストは詳細に 3 回再試行されます。同じ runName で合計 4 回実行する必要があり、attemptNumber は 0 から 3 です。 |
startTime | long : 実行が開始された時間、 ERROR(/System#currentTimeMillis()) で測定 |
testRunStopped
public void testRunStopped (long elapsedTime)
レポートのテスト実行は、ユーザーの要求により完了前に停止しました。
TODO: 現在使用されていません。削除を検討してください
パラメーター | |
---|---|
elapsedTime | long : デバイスが報告した経過時間 (ミリ秒) |
テスト開始
public void testStarted (TestDescription test, long startTime)
testStarted(com.android.tradefed.result.TestDescription)
の代わりに、正確な測定のためERROR(/#testEnded(com.android.tradefed.result.TestDescription,long,Map))
と組み合わせて、テストの開始時期も指定します。 .
パラメーター | |
---|---|
test | TestDescription : テストを識別します |
startTime | long : ERROR(/System#currentTimeMillis()) を介して測定された、テストの開始時間 |
テスト開始
public void testStarted (TestDescription test)
個々のテスト ケースの開始を報告します。古いインターフェースでは、可能な限りtestStarted(com.android.tradefed.result.TestDescription)
を使用する必要があります。
パラメーター | |
---|---|
test | TestDescription : テストを識別します |
保護されたメソッド
clearModuleLogFiles
protected final void clearModuleLogFiles ()
モジュールファイルのクリーニングを許可して、長時間持ち歩くことを避けます。
clearResultsForName
protected final void clearResultsForName (String testRunName)
特定の実行名の結果をクリアできます。結果のアグリゲーターなどの場合にのみ使用する必要があります。
パラメーター | |
---|---|
testRunName | String |
setIsAggregrateMetrics
protected void setIsAggregrateMetrics (boolean aggregate)
「集計メトリクス」オプションを切り替えます
パラメーター | |
---|---|
aggregate | boolean |