測試結果監聽器
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) 當原子測試標記它假定條件為假時調用 |
final void | testEnded ( TestDescription test, testMetrics) testEnded ( TestDescription test, testMetrics) 報告單個測試用例的執行結束。 |
final void | testEnded ( TestDescription test, long endTime, testMetrics) testEnded ( TestDescription test, long endTime, 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, runMetrics) testRunEnded (long elapsedTimeMillis, runMetrics) 報告測試運行結束。 |
final void | testStarted ( TestDescription test, long startTime) |
final void | testStarted ( TestDescription test) 報告單個測試用例的開始。 |
公共構造函數
測試結果監聽器
public TestResultListener ()
公共方法
測試假設失敗
public final void testAssumptionFailure (TestDescription test, String trace)
當原子測試標記它假定條件為假時調用
參數 | |
---|---|
test | TestDescription :標識測試 |
trace | String :失敗的堆棧跟踪 |
測試結束
public final void testEnded (TestDescription test,testMetrics)
報告單個測試用例的執行結束。
如果未調用testFailed(TestDescription, FailureDescription)
,則此測試通過。還返回在測試用例執行期間可能發出的任何鍵/值指標。
參數 | |
---|---|
test | TestDescription :標識測試 |
testMetrics | ERROR(/Map) |
測試結束
public final 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 final void testFailed (TestDescription test, String trace)
報告單個測試用例的失敗。
將在 testStarted 和 testEnded 之間調用。
參數 | |
---|---|
test | TestDescription :標識測試 |
trace | String :失敗的堆棧跟踪 |
測試忽略
public final void testIgnored (TestDescription test)
當測試不會運行時調用,通常是因為測試方法用 org.junit.Ignore 註釋。
參數 | |
---|---|
test | TestDescription :標識測試 |
測試結果
public abstract void testResult (TestDescription test, TestResult result)
參數 | |
---|---|
test | TestDescription |
result | TestResult |
測試運行結束
public void testRunEnded (long elapsedTimeMillis,runMetrics)
報告測試運行結束。 FIXME: 我們不能有兩個不同類型的 Map<> 接口,所以我們必須在這裡使用 HashMap。
參數 | |
---|---|
elapsedTimeMillis | long :設備報告經過的時間,以毫秒為單位 |
runMetrics | Metric 報告的鍵值對。 |
測試開始
public final 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 final void testStarted (TestDescription test)
報告單個測試用例的開始。較舊的界面,應盡可能使用testStarted(com.android.tradefed.result.TestDescription)
。
參數 | |
---|---|
test | TestDescription :標識測試 |