TestResultListener
public
abstract
class
TestResultListener
extends Object
implements
ITestLifeCycleReceiver
| java.lang.Object | |
| ↳ | com.android.tradefed.result.TestResultListener |
簡化 ITestLifecycleListener,方便實作者只關注個別測試結果。
將各種生命週期事件篩選至 testResult 方法。
這並非執行緒安全,特別是假設 ITestLifecycleListener 事件是依序接收。
摘要
公用建構函式 | |
|---|---|
TestResultListener()
|
|
公用方法 | |
|---|---|
final
void
|
testAssumptionFailure(TestDescription test, String trace)
當原子測試標記假設為 false 的條件時,系統會呼叫這個函式 |
final
void
|
testEnded(TestDescription test, long endTime, Map<String, String> testMetrics)
|
final
void
|
testEnded(TestDescription test, long endTime, HashMap<String, MetricMeasurement.Metric> testMetrics)
|
final
void
|
testEnded(TestDescription test, Map<String, String> testMetrics)
回報個別測試案例的執行結束時間。 |
final
void
|
testEnded(TestDescription test, HashMap<String, MetricMeasurement.Metric> testMetrics)
回報個別測試案例的執行結束時間。 |
final
void
|
testFailed(TestDescription test, String trace)
回報個別測試案例的失敗情形。 |
final
void
|
testIgnored(TestDescription test)
當測試不會執行時呼叫,通常是因為測試方法以 org.junit.Ignore 註解標註。 |
abstract
void
|
testResult(TestDescription test, TestResult result)
|
void
|
testRunEnded(long elapsedTimeMillis, HashMap<String, MetricMeasurement.Metric> runMetrics)
Reports end of test run. |
void
|
testSkipped(TestDescription test, SkipReason reason)
Called when a test is skipped and did not execute for a reason that is not usually expected. |
final
void
|
testStarted(TestDescription test, long startTime)
|
final
void
|
testStarted(TestDescription test)
回報個別測試案例的開始時間。 |
公用建構函式
TestResultListener
public TestResultListener ()
公用方法
testAssumptionFailure
public final void testAssumptionFailure (TestDescription test, String trace)
當原子測試標記假設為 false 的條件時呼叫
| 參數 | |
|---|---|
test |
TestDescription:識別測試 |
trace |
String:失敗的堆疊追蹤 |
testEnded
public final void testEnded (TestDescription test, long endTime, Map<String, String> testMetrics)
testEnded(TestDescription,Map) 的替代方案,可直接指定結束時間。搭配 testStarted(TestDescription,long) 使用,可準確測量。
| 參數 | |
|---|---|
test |
TestDescription:識別測試 |
endTime |
long:測試結束時間,透過 System.currentTimeMillis() 測量 |
testMetrics |
Map:發出的指標 Map |
testEnded
public final void testEnded (TestDescription test, long endTime, HashMap<String, MetricMeasurement.Metric> testMetrics)
testEnded(TestDescription,Map) 的替代方案,可直接指定結束時間。搭配 testStarted(TestDescription,long) 使用,可準確測量。
| 參數 | |
|---|---|
test |
TestDescription:識別測試 |
endTime |
long:測試結束時間,透過 System.currentTimeMillis() 測量 |
testMetrics |
HashMap:發出的指標 Map |
testEnded
public final void testEnded (TestDescription test, Map<String, String> testMetrics)
回報個別測試案例的執行結束時間。
如果未叫用 testFailed(TestDescription, FailureDescription),這項測試就會通過。也會傳回測試案例執行期間可能發出的任何鍵/值指標。
| 參數 | |
|---|---|
test |
TestDescription:識別測試 |
testMetrics |
Map:發出的指標 Map |
testEnded
public final void testEnded (TestDescription test, HashMap<String, MetricMeasurement.Metric> testMetrics)
回報個別測試案例的執行結束時間。
如果未叫用 testFailed(TestDescription, FailureDescription),這項測試就會通過。也會傳回測試案例執行期間可能發出的任何鍵/值指標。
| 參數 | |
|---|---|
test |
TestDescription:識別測試 |
testMetrics |
HashMap:發出的指標 Map |
testFailed
public final void testFailed (TestDescription test, String trace)
回報個別測試案例的失敗情形。
會在 testStarted 和 testEnded 之間呼叫。
| 參數 | |
|---|---|
test |
TestDescription:識別測試 |
trace |
String:失敗的堆疊追蹤 |
testIgnored
public final void testIgnored (TestDescription test)
當測試不會執行時呼叫,通常是因為測試方法以 org.junit.Ignore 註解標註。
| 參數 | |
|---|---|
test |
TestDescription:識別測試 |
testResult
public abstract void testResult (TestDescription test, TestResult result)
| 參數 | |
|---|---|
test |
TestDescription |
result |
TestResult |
testRunEnded
public void testRunEnded (long elapsedTimeMillis,
HashMap<String, MetricMeasurement.Metric> runMetrics)測試執行結束時會回報。FIXME:我們無法使用不同型別的兩個 Map<> 介面,因此必須在此使用 HashMap。
| 參數 | |
|---|---|
elapsedTimeMillis |
long:裝置回報的經過時間 (以毫秒為單位) |
runMetrics |
HashMap:在測試執行結束時,使用 Metric 報告的鍵/值組合。 |
testSkipped
public void testSkipped (TestDescription test, SkipReason reason)
Called when a test is skipped and did not execute for a reason that is not usually expected. 系統會嘗試重試這些測試,以確保正常執行。
| 參數 | |
|---|---|
test |
TestDescription:識別測試 |
reason |
SkipReason:SkipReason |
testStarted
public final void testStarted (TestDescription test, long startTime)
testStarted(TestDescription) 的替代方案,我們也會指定測試開始時間,並搭配 testEnded(TestDescription,long,Map) 進行準確的評估。
| 參數 | |
|---|---|
test |
TestDescription:識別測試 |
startTime |
long:測試開始時間,透過 System.currentTimeMillis() 測量 |
testStarted
public final void testStarted (TestDescription test)
回報個別測試案例的開始時間。舊版介面,建議盡可能使用 testStarted(TestDescription)。
| 參數 | |
|---|---|
test |
TestDescription:識別測試 |