TestRunResult

public class TestRunResult
extends Object implements ITestRunListener

java.lang.Object
   ↳ com.android.ddmlib.testrunner.TestRunResult


保存單一測試執行的結果。

維持準確的測試次數,並追蹤未完成的測試。

這並非執行緒安全!測試* 回呼必須依序呼叫

摘要

公用建構函式

TestRunResult()

建立空白的 TestRunResult

公用方法

Set<TestIdentifier> getCompletedTests()

取得已完成的測試集。

long getElapsedTime()

傳回目前執行作業的經過時間。

String getName()
int getNumAllFailedTests()

傳回處於失敗狀態的測試總數 (失敗、假設失敗)

int getNumCompleteTests()

Gets the number of complete tests in this run ie with status != incomplete.

int getNumTests()

取得這項執行作業中的測試數量。

int getNumTestsInState(TestResult.TestStatus status)

Gets the number of tests in given state for this run.

String getRunFailureMessage()

如果執行作業未失敗,則傳回執行作業失敗錯誤訊息 null

Map<String, String> getRunMetrics()
Map<TestIdentifierTestResult> getTestResults()

傳回測試結果的地圖。

String getTextSummary()

傳回描述結果的易讀字串。

boolean hasFailedTests()
boolean isRunComplete()
boolean isRunFailure()
void setAggregateMetrics(boolean metricAggregation)
void setRunComplete(boolean runComplete)
void testAssumptionFailure(TestIdentifier test, String trace)

當原子測試標記假設為 false 的條件時,系統會呼叫這個函式

void testEnded(TestIdentifier test, Map<String, String> testMetrics)

回報個別測試案例的執行結束時間。

void testFailed(TestIdentifier test, String trace)

回報個別測試案例的失敗情形。

void testIgnored(TestIdentifier test)

當測試不會執行時呼叫,通常是因為測試方法以 org.junit.Ignore 註解標註。

void testRunEnded(long elapsedTime, Map<String, String> runMetrics)

Reports end of test run.

void testRunFailed(String errorMessage)

發生嚴重錯誤,因此無法完成報表測試執行。

void testRunStarted(String runName, int testCount)

回報測試執行的開始。

void testRunStopped(long elapsedTime)

由於使用者要求,報表測試執行作業在完成前停止。

void testStarted(TestIdentifier test)

回報個別測試案例的開始時間。

公用建構函式

TestRunResult

public TestRunResult ()

建立空白的 TestRunResult

公用方法

getCompletedTests

public Set<TestIdentifier> getCompletedTests ()

取得已完成的測試集。

傳回
Set<TestIdentifier>

getElapsedTime

public long getElapsedTime ()

傳回目前執行作業的經過時間。

傳回
long

getName

public String getName ()

傳回
String 測試執行名稱

getNumAllFailedTests

public int getNumAllFailedTests ()

傳回處於失敗狀態的測試總數 (失敗、假設失敗)

傳回
int

getNumCompleteTests

public int getNumCompleteTests ()

取得這項執行作業中已完成的測試數量,也就是狀態 != incomplete。

傳回
int

getNumTests

public int getNumTests ()

取得這次執行中的測試數量。

傳回
int

getNumTestsInState

public int getNumTestsInState (TestResult.TestStatus status)

取得這項執行作業中處於指定狀態的測試數量。

參數
status TestResult.TestStatus

傳回
int

getRunFailureMessage

public String getRunFailureMessage ()

如果執行作業未失敗,則傳回執行作業失敗錯誤訊息 null

傳回
String

getRunMetrics

public Map<String, String> getRunMetrics ()

傳回
Map<String, String> 測試執行指標的 Map

getTestResults

public Map<TestIdentifierTestResult> getTestResults ()

傳回測試結果的地圖。

傳回
Map<TestIdentifierTestResult>

getTextSummary

public String getTextSummary ()

傳回描述結果的易讀字串。

傳回
String

hasFailedTests

public boolean hasFailedTests ()

傳回
boolean true 如果測試執行期間有任何測試失敗或發生錯誤。

isRunComplete

public boolean isRunComplete ()

傳回
boolean true (如果測試執行作業已完成)。

isRunFailure

public boolean isRunFailure ()

傳回
boolean true 如果測試執行失敗。

setAggregateMetrics

public void setAggregateMetrics (boolean metricAggregation)

參數
metricAggregation boolean

setRunComplete

public void setRunComplete (boolean runComplete)

參數
runComplete boolean

testAssumptionFailure

public void testAssumptionFailure (TestIdentifier test, 
                String trace)

當原子測試標記假設為 false 的條件時呼叫

參數
test TestIdentifier:識別測試

trace String:失敗的堆疊追蹤

testEnded

public void testEnded (TestIdentifier test, 
                Map<String, String> testMetrics)

回報個別測試案例的執行結束時間。

如果未叫用 testFailed(TestIdentifier, String),這項測試就會通過。也會傳回測試案例執行期間可能發出的任何鍵/值指標。

參數
test TestIdentifier:識別測試

testMetrics Mapandroid.app.Instrumentation#sendStatus 在執行測試案例期間發出的指標 Map。除非您多次發出相同鍵,否則系統會保留插入順序。請注意,系統會從這個 Map 中篩除 IInstrumentationResultParser.StatusKeys 中定義的標準鍵。Ddmlib 可能會新增 IInstrumentationResultParser.StatusKeys 中定義的額外測試指標。

testFailed

public void testFailed (TestIdentifier test, 
                String trace)

回報個別測試案例的失敗情形。

會在 testStarted 和 testEnded 之間呼叫。

參數
test TestIdentifier:識別測試

trace String:失敗的堆疊追蹤

testIgnored

public void testIgnored (TestIdentifier test)

當測試不會執行時呼叫,通常是因為測試方法以 org.junit.Ignore 註解標註。

參數
test TestIdentifier:識別測試

testRunEnded

public void testRunEnded (long elapsedTime, 
                Map<String, String> runMetrics)

測試執行結束時的報告。

參數
elapsedTime long:裝置回報的經過時間 (以毫秒為單位)

runMetrics Mapandroid.app.Instrumentation#addResults 在執行測試案例期間發出的指標 Map。除非您多次發出相同鍵,否則系統會保留插入順序。請注意,系統會從這個 Map 中篩除 IInstrumentationResultParser.StatusKeys 中定義的標準鍵。Ddmlib 可能會新增 IInstrumentationResultParser.StatusKeys 中定義的額外測試指標。

testRunFailed

public void testRunFailed (String errorMessage)

發生嚴重錯誤,因此無法完成報表測試執行作業。

參數
errorMessage StringString,說明執行失敗的原因。

testRunStarted

public void testRunStarted (String runName, 
                int testCount)

回報測試執行的開始時間。

參數
runName String:測試執行名稱

testCount int:測試執行作業中的測試總數

testRunStopped

public void testRunStopped (long elapsedTime)

由於使用者要求,報表測試執行作業在完成前停止。

參數
elapsedTime long:裝置回報的經過時間 (以毫秒為單位)

testStarted

public void testStarted (TestIdentifier test)

回報個別測試案例的開始時間。

參數
test TestIdentifier:識別測試