Package com.android.ddmlib.testrunner
Class XmlTestRunListener
- java.lang.Object
-
- com.android.ddmlib.testrunner.XmlTestRunListener
-
- All Implemented Interfaces:
ITestRunListener
public class XmlTestRunListener extends java.lang.Object implements ITestRunListener
Writes JUnit results to an XML files in a format consistent with Ant's XMLJUnitResultFormatter.Creates a separate XML file per test run.
- See Also:
- "https://svn.jenkins-ci.org/trunk/hudson/dtkit/dtkit-format/dtkit-junit-model/src/main/resources/com/thalesgroup/dtkit/junit/model/xsd/junit-4.xsd"
-
-
Constructor Summary
Constructors Constructor Description XmlTestRunListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Map<java.lang.String,java.lang.String>
getPropertiesAttributes()
Get the properties attributes as key value pairs to be included in the test report.protected java.io.File
getResultFile(java.io.File reportDir)
Creates aFile
where the report will be created.TestRunResult
getRunResult()
Returns theTestRunResult
protected java.lang.String
getTestName(TestIdentifier testId)
protected java.lang.String
getTestSuiteName()
void
setHostName(java.lang.String hostName)
void
setReportDir(java.io.File file)
Sets the report file to use.void
testAssumptionFailure(TestIdentifier test, java.lang.String trace)
Called when an atomic test flags that it assumes a condition that is falsevoid
testEnded(TestIdentifier test, java.util.Map<java.lang.String,java.lang.String> testMetrics)
Reports the execution end of an individual test case.void
testFailed(TestIdentifier test, java.lang.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, java.util.Map<java.lang.String,java.lang.String> runMetrics)
Reports end of test run.void
testRunFailed(java.lang.String errorMessage)
Reports test run failed to complete due to a fatal error.void
testRunStarted(java.lang.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.
-
-
-
Method Detail
-
setReportDir
public void setReportDir(java.io.File file)
Sets the report file to use.
-
setHostName
public void setHostName(java.lang.String hostName)
-
getRunResult
public TestRunResult getRunResult()
Returns theTestRunResult
- Returns:
- the test run results.
-
testRunStarted
public void testRunStarted(java.lang.String runName, int numTests)
Description copied from interface:ITestRunListener
Reports the start of a test run.- Specified by:
testRunStarted
in interfaceITestRunListener
- Parameters:
runName
- the test run namenumTests
- total number of tests in test run
-
testStarted
public void testStarted(TestIdentifier test)
Description copied from interface:ITestRunListener
Reports the start of an individual test case.- Specified by:
testStarted
in interfaceITestRunListener
- Parameters:
test
- identifies the test
-
testFailed
public void testFailed(TestIdentifier test, java.lang.String trace)
Description copied from interface:ITestRunListener
Reports the failure of a individual test case.Will be called between testStarted and testEnded.
- Specified by:
testFailed
in interfaceITestRunListener
- Parameters:
test
- identifies the testtrace
- stack trace of failure
-
testAssumptionFailure
public void testAssumptionFailure(TestIdentifier test, java.lang.String trace)
Description copied from interface:ITestRunListener
Called when an atomic test flags that it assumes a condition that is false- Specified by:
testAssumptionFailure
in interfaceITestRunListener
- Parameters:
test
- identifies the testtrace
- stack trace of failure
-
testIgnored
public void testIgnored(TestIdentifier test)
Description copied from interface:ITestRunListener
Called when a test will not be run, generally because a test method is annotated with org.junit.Ignore.- Specified by:
testIgnored
in interfaceITestRunListener
- Parameters:
test
- identifies the test
-
testEnded
public void testEnded(TestIdentifier test, java.util.Map<java.lang.String,java.lang.String> testMetrics)
Description copied from interface:ITestRunListener
Reports the execution end of an individual test case.If
ITestRunListener.testFailed(com.android.ddmlib.testrunner.TestIdentifier, java.lang.String)
was not invoked, this test passed. Also returns any key/value metrics which may have been emitted during the test case's execution.- Specified by:
testEnded
in interfaceITestRunListener
- Parameters:
test
- identifies the testtestMetrics
- aMap
of the metrics emitted
-
testRunFailed
public void testRunFailed(java.lang.String errorMessage)
Description copied from interface:ITestRunListener
Reports test run failed to complete due to a fatal error.- Specified by:
testRunFailed
in interfaceITestRunListener
- Parameters:
errorMessage
-String
describing reason for run failure.
-
testRunStopped
public void testRunStopped(long elapsedTime)
Description copied from interface:ITestRunListener
Reports test run stopped before completion due to a user request.TODO: currently unused, consider removing
- Specified by:
testRunStopped
in interfaceITestRunListener
- Parameters:
elapsedTime
- device reported elapsed time, in milliseconds
-
testRunEnded
public void testRunEnded(long elapsedTime, java.util.Map<java.lang.String,java.lang.String> runMetrics)
Description copied from interface:ITestRunListener
Reports end of test run.- Specified by:
testRunEnded
in interfaceITestRunListener
- Parameters:
elapsedTime
- device reported elapsed time, in millisecondsrunMetrics
- key-value pairs reported at the end of a test run
-
getResultFile
protected java.io.File getResultFile(java.io.File reportDir) throws java.io.IOException
Creates aFile
where the report will be created.- Parameters:
reportDir
- the root directory of the report.- Returns:
- a file
- Throws:
java.io.IOException
-
getTestSuiteName
protected java.lang.String getTestSuiteName()
-
getPropertiesAttributes
@NonNull protected java.util.Map<java.lang.String,java.lang.String> getPropertiesAttributes()
Get the properties attributes as key value pairs to be included in the test report.
-
getTestName
protected java.lang.String getTestName(TestIdentifier testId)
-
-