XmlTestRunListener
public
class
XmlTestRunListener
extends Object
implements
ITestRunListener
| java.lang.Object | |
| ↳ | com.android.ddmlib.testrunner.XmlTestRunListener |
以符合 Ant 的 XMLJUnitResultFormatter 格式,將 JUnit 結果寫入 XML 檔案。
為每次測試執行作業建立個別的 XML 檔案。
摘要
公用建構函式 | |
|---|---|
XmlTestRunListener()
|
|
公用方法 | |
|---|---|
void
|
addSystemError(String systemError)
新增系統錯誤訊息。 |
TestRunResult
|
getRunResult()
|
String
|
getSystemError()
傳回要寫入 XML 檔案「system-err」元素中的系統錯誤訊息。 |
void
|
setHostName(String hostName)
|
void
|
setReportDir(File file)
設定要使用的報表檔案。 |
void
|
testAssumptionFailure(TestIdentifier test, String trace)
當原子測試標記假設條件為 false 時,系統會呼叫這個函式。 |
void
|
testEnded(TestIdentifier test,
回報個別測試案例的執行結束時間。 |
void
|
testFailed(TestIdentifier test, String trace)
回報個別測試案例的失敗情形。 |
void
|
testIgnored(TestIdentifier test)
Called when a test will not be run, generally because a test method is annotated with org.junit.Ignore. |
void
|
testRunEnded(long elapsedTime,
Reports end of test run. |
void
|
testRunFailed(String errorMessage)
由於發生嚴重錯誤,報表測試執行作業無法完成。 |
void
|
testRunStarted(String runName, int numTests)
回報測試執行的開始時間。 |
void
|
testRunStopped(long elapsedTime)
由於使用者要求,報表測試執行作業在完成前停止。 |
void
|
testStarted(TestIdentifier test)
回報個別測試案例的開始時間。 |
受保護的方法 | |
|---|---|
|
getPropertiesAttributes()
以鍵/值組合形式取得屬性屬性,以便納入測試報告。 |
File
|
getResultFile(File reportDir)
建立 |
String
|
getTestName(TestIdentifier testId)
|
String
|
getTestSuiteName()
|
公用建構函式
XmlTestRunListener
public XmlTestRunListener ()
公用方法
addSystemError
public void addSystemError (String systemError)
新增系統錯誤訊息。
| 參數 | |
|---|---|
systemError |
String |
getSystemError
public String getSystemError ()
傳回要寫入 XML 檔案「system-err」元素中的系統錯誤訊息。如果傳回空白字串,系統就不會建立元素。
| 傳回 | |
|---|---|
String |
|
setHostName
public void setHostName (String hostName)
| 參數 | |
|---|---|
hostName |
String |
setReportDir
public void setReportDir (File file)
設定要使用的報表檔案。
| 參數 | |
|---|---|
file |
File |
testAssumptionFailure
public void testAssumptionFailure (TestIdentifier test, String trace)
當原子測試標記假設為 false 的條件時呼叫
| 參數 | |
|---|---|
test |
TestIdentifier:識別測試 |
trace |
String:失敗的堆疊追蹤 |
testEnded
public void testEnded (TestIdentifier test,testMetrics)
回報個別測試案例的執行結束時間。
如果未叫用 testFailed(TestIdentifier, String),這項測試就會通過。也會傳回在測試案例執行期間可能發出的任何鍵/值指標。
| 參數 | |
|---|---|
test |
TestIdentifier:識別測試 |
testMetrics |
:android.app.Instrumentation#sendStatus 在執行測試案例期間發出的指標 ERROR(/Map)。除非您多次發出相同鍵,否則系統會保留插入順序。請注意,IInstrumentationResultParser.StatusKeys 中定義的標準鍵會從這個 Map 中篩除。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,
runMetrics) 報告測試執行結束時間。
| 參數 | |
|---|---|
elapsedTime |
long:裝置回報的經過時間 (以毫秒為單位) |
runMetrics |
:android.app.Instrumentation#addResults 在執行測試案例期間發出的指標 ERROR(/Map)。除非您多次發出相同鍵,否則系統會保留插入順序。請注意,IInstrumentationResultParser.StatusKeys 中定義的標準鍵會從這個 Map 中篩除。Ddmlib 可能會加入 IInstrumentationResultParser.StatusKeys 中定義的額外測試指標。 |
testRunFailed
public void testRunFailed (String errorMessage)
發生嚴重錯誤,導致報表測試執行作業無法完成。
| 參數 | |
|---|---|
errorMessage |
String:String,說明執行失敗的原因。 |
testRunStarted
public void testRunStarted (String runName,
int numTests)回報測試執行的開始時間。
| 參數 | |
|---|---|
runName |
String:測試執行作業名稱 |
numTests |
int:測試執行作業中的測試總數 |
testRunStopped
public void testRunStopped (long elapsedTime)
由於使用者要求,報表測試執行作業在完成前停止。
| 參數 | |
|---|---|
elapsedTime |
long:裝置回報的經過時間 (以毫秒為單位) |
testStarted
public void testStarted (TestIdentifier test)
回報個別測試案例的開始時間。
| 參數 | |
|---|---|
test |
TestIdentifier:識別測試 |
受保護的方法
getPropertiesAttributes
protectedgetPropertiesAttributes ()
以鍵/值組合形式取得屬性屬性,以便納入測試報告。
| 傳回 | |
|---|---|
|
|
getResultFile
protected File getResultFile (File reportDir)
建立 ERROR(/File),報表將建立於此。
| 參數 | |
|---|---|
reportDir |
File:報表的根目錄。 |
| 傳回 | |
|---|---|
File |
檔案 |
| 擲回 | |
|---|---|
|
IOException |
getTestSuiteName
protected String getTestSuiteName ()
| 傳回 | |
|---|---|
String |
|