XmlTestRunListener
public
class
XmlTestRunListener
extends Object
implements
ITestRunListener
| java.lang.Object | |
| ↳ | com.android.ddmlib.testrunner.XmlTestRunListener |
Writes JUnit results to an XML files in a format consistent with Ant's XMLJUnitResultFormatter.
Creates a separate XML file per test run.
Summary
Public constructors | |
|---|---|
XmlTestRunListener()
|
|
Public methods | |
|---|---|
void
|
addSystemError(String systemError)
Add system error message. |
TestRunResult
|
getRunResult()
Returns the |
String
|
getSystemError()
Returns the system error message to be written into XML file in "system-err" element. |
void
|
setHostName(String hostName)
|
void
|
setReportDir(File file)
Sets the report file to use. |
void
|
testAssumptionFailure(TestIdentifier test, String trace)
Called when an atomic test flags that it assumes a condition that is false |
void
|
testEnded(TestIdentifier test,
Reports the execution end of an individual test case. |
void
|
testFailed(TestIdentifier test, String trace)
Reports the failure of a individual test case. |
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)
Reports test run failed to complete due to a fatal error. |
void
|
testRunStarted(String runName, int numTests)
Reports the start of a test run. |
void
|
testRunStopped(long elapsedTime)
Reports test run stopped before completion due to a user request. |
void
|
testStarted(TestIdentifier test)
Reports the start of an individual test case. |
Protected methods | |
|---|---|
|
getPropertiesAttributes()
Get the properties attributes as key value pairs to be included in the test report. |
File
|
getResultFile(File reportDir)
Creates a |
String
|
getTestName(TestIdentifier testId)
|
String
|
getTestSuiteName()
|
Public constructors
XmlTestRunListener
public XmlTestRunListener ()
Public methods
addSystemError
public void addSystemError (String systemError)
Add system error message.
| Parameters | |
|---|---|
systemError |
String |
getRunResult
public TestRunResult getRunResult ()
Returns the TestRunResult
| Returns | |
|---|---|
TestRunResult |
the test run results. |
getSystemError
public String getSystemError ()
Returns the system error message to be written into XML file in "system-err" element. The element is not created if this returns an empty string.
| Returns | |
|---|---|
String |
|
setHostName
public void setHostName (String hostName)
| Parameters | |
|---|---|
hostName |
String |
setReportDir
public void setReportDir (File file)
Sets the report file to use.
| Parameters | |
|---|---|
file |
File |
testAssumptionFailure
public void testAssumptionFailure (TestIdentifier test, String trace)
Called when an atomic test flags that it assumes a condition that is false
| Parameters | |
|---|---|
test |
TestIdentifier: identifies the test |
trace |
String: stack trace of failure |
testEnded
public void testEnded (TestIdentifier test,testMetrics)
Reports the execution end of an individual test case.
If testFailed(TestIdentifier, String) was not invoked, this test passed. Also returns any key/value
metrics which may have been emitted during the test case's execution.
| Parameters | |
|---|---|
test |
TestIdentifier: identifies the test |
testMetrics |
: a ERROR(/Map) of the metrics emitted during the execution of the test case
by android.app.Instrumentation#sendStatus. The insertion order is preserved
unless you emit a same key multiple times. Note that standard keys defined in IInstrumentationResultParser.StatusKeys are filtered out of this Map. Ddmlib may add
extra test metrics defined in IInstrumentationResultParser.StatusKeys. |
testFailed
public void testFailed (TestIdentifier test, String trace)
Reports the failure of a individual test case.
Will be called between testStarted and testEnded.
| Parameters | |
|---|---|
test |
TestIdentifier: identifies the test |
trace |
String: stack trace of failure |
testIgnored
public void testIgnored (TestIdentifier test)
Called when a test will not be run, generally because a test method is annotated with org.junit.Ignore.
| Parameters | |
|---|---|
test |
TestIdentifier: identifies the test |
testRunEnded
public void testRunEnded (long elapsedTime,
runMetrics) Reports end of test run.
| Parameters | |
|---|---|
elapsedTime |
long: device reported elapsed time, in milliseconds |
runMetrics |
: a ERROR(/Map) of the metrics emitted during the execution of the test case
by android.app.Instrumentation#addResults. The insertion order is preserved
unless you emit a same key multiple times. Note that standard keys defined in IInstrumentationResultParser.StatusKeys are filtered out of this Map. Ddmlib may add
extra test metrics defined in IInstrumentationResultParser.StatusKeys. |
testRunFailed
public void testRunFailed (String errorMessage)
Reports test run failed to complete due to a fatal error.
| Parameters | |
|---|---|
errorMessage |
String: String describing reason for run failure. |
testRunStarted
public void testRunStarted (String runName,
int numTests)Reports the start of a test run.
| Parameters | |
|---|---|
runName |
String: the test run name |
numTests |
int: total number of tests in test run |
testRunStopped
public void testRunStopped (long elapsedTime)
Reports test run stopped before completion due to a user request.
| Parameters | |
|---|---|
elapsedTime |
long: device reported elapsed time, in milliseconds |
testStarted
public void testStarted (TestIdentifier test)
Reports the start of an individual test case.
| Parameters | |
|---|---|
test |
TestIdentifier: identifies the test |
Protected methods
getPropertiesAttributes
protectedgetPropertiesAttributes ()
Get the properties attributes as key value pairs to be included in the test report.
| Returns | |
|---|---|
|
|
getResultFile
protected File getResultFile (File reportDir)
Creates a ERROR(/File) where the report will be created.
| Parameters | |
|---|---|
reportDir |
File: the root directory of the report. |
| Returns | |
|---|---|
File |
a file |
| Throws | |
|---|---|
|
IOException |
getTestName
protected String getTestName (TestIdentifier testId)
| Parameters | |
|---|---|
testId |
TestIdentifier |
| Returns | |
|---|---|
String |
|
getTestSuiteName
protected String getTestSuiteName ()
| Returns | |
|---|---|
String |
|