public class JUnitXMLReporter extends java.lang.Object implements IResultListener2
Modifier and Type | Field and Description |
---|---|
private static java.util.Map<java.lang.String,java.util.regex.Pattern> |
ATTR_ESCAPES |
private static java.util.regex.Pattern |
ENTITY |
private static java.util.regex.Pattern |
GREATER |
private static java.util.regex.Pattern |
LESS |
private java.util.Queue<ITestResult> |
m_allTests |
private java.util.Queue<ITestResult> |
m_configIssues |
private int |
m_fileNameIncrementer |
private java.util.Map<java.lang.String,java.lang.String> |
m_fileNameMap |
private int |
m_numFailed |
private static java.util.regex.Pattern |
QUOTE |
private static java.util.regex.Pattern |
SINGLE_QUOTE |
Constructor and Description |
---|
JUnitXMLReporter() |
Modifier and Type | Method and Description |
---|---|
void |
beforeConfiguration(ITestResult tr)
Invoked before a configuration method is invoked.
|
private void |
createElement(XMLStringBuffer doc,
ITestResult tr) |
private void |
createElementFromIgnoredTests(XMLStringBuffer doc,
ITestContext context) |
private void |
createElementFromTestResults(XMLStringBuffer document,
java.util.Collection<ITestResult> results) |
private void |
createFailureElement(XMLStringBuffer doc,
ITestResult tr) |
private void |
createSkipElement(XMLStringBuffer doc) |
private java.lang.String |
encodeAttr(java.lang.String attr) |
(package private) static java.lang.String |
formattedTime() |
private java.lang.String |
generateFileName(ITestContext context)
This method guarantees unique file names for reports.
Also, this will guarantee that the old reports are overwritten when tests are run again. |
protected void |
generateReport(ITestContext context)
generate the XML report given what we know from all the test results
|
private java.util.Set<java.lang.String> |
getPackages(ITestContext context) |
private java.util.Properties |
getPropertiesFor(ITestNGMethod method,
long elapsedTimeMillis) |
void |
onConfigurationFailure(ITestResult itr)
Invoked whenever a configuration method failed.
|
void |
onConfigurationSkip(ITestResult itr)
Invoked whenever a configuration method was skipped.
|
void |
onConfigurationSuccess(ITestResult itr)
Invoked whenever a configuration method succeeded.
|
void |
onFinish(ITestContext context)
Invoked after all the tests have run and all their Configuration methods have been called.
|
void |
onStart(ITestContext context)
Invoked after the test class is instantiated and before any configuration method is called.
|
void |
onTestFailedButWithinSuccessPercentage(ITestResult tr)
Invoked each time a method fails but has been annotated with successPercentage and this failure
still keeps it within the success percentage requested.
|
void |
onTestFailure(ITestResult tr)
Invoked each time a test fails.
|
void |
onTestSkipped(ITestResult tr)
Invoked each time a test is skipped.
|
void |
onTestStart(ITestResult result)
Invoked each time before a test will be invoked.
|
void |
onTestSuccess(ITestResult tr)
Invoked each time a test succeeds.
|
private java.lang.String |
replaceAmpersand(java.lang.String str,
java.util.regex.Pattern pattern) |
private void |
resetAll()
Reset all member variables for next test.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onTestFailedWithTimeout
private static final java.util.regex.Pattern ENTITY
private static final java.util.regex.Pattern LESS
private static final java.util.regex.Pattern GREATER
private static final java.util.regex.Pattern SINGLE_QUOTE
private static final java.util.regex.Pattern QUOTE
private static final java.util.Map<java.lang.String,java.util.regex.Pattern> ATTR_ESCAPES
private int m_numFailed
private java.util.Queue<ITestResult> m_allTests
private java.util.Queue<ITestResult> m_configIssues
private java.util.Map<java.lang.String,java.lang.String> m_fileNameMap
private int m_fileNameIncrementer
public void onTestStart(ITestResult result)
ITestListener
ITestResult
is only partially
filled with the references to class, method, start millis and status.onTestStart
in interface ITestListener
result
- the partially filled ITestResult
ITestResult.STARTED
public void beforeConfiguration(ITestResult tr)
IConfigurationListener
beforeConfiguration
in interface IConfigurationListener
public void onTestSuccess(ITestResult tr)
onTestSuccess
in interface ITestListener
tr
- ITestResult
containing information about the run testITestResult.SUCCESS
public void onTestFailedButWithinSuccessPercentage(ITestResult tr)
ITestListener
onTestFailedButWithinSuccessPercentage
in interface ITestListener
tr
- ITestResult
containing information about the run testITestResult.SUCCESS_PERCENTAGE_FAILURE
public void onTestFailure(ITestResult tr)
onTestFailure
in interface ITestListener
tr
- ITestResult
containing information about the run testITestResult.FAILURE
public void onTestSkipped(ITestResult tr)
onTestSkipped
in interface ITestListener
tr
- ITestResult
containing information about the run testITestResult.SKIP
public void onStart(ITestContext context)
onStart
in interface ITestListener
public void onFinish(ITestContext context)
onFinish
in interface ITestListener
public void onConfigurationFailure(ITestResult itr)
IConfigurationListener
onConfigurationFailure
in interface IConfigurationListener
IConfigurationListener.onConfigurationFailure(org.testng.ITestResult)
public void onConfigurationSkip(ITestResult itr)
IConfigurationListener
onConfigurationSkip
in interface IConfigurationListener
IConfigurationListener.onConfigurationSkip(org.testng.ITestResult)
public void onConfigurationSuccess(ITestResult itr)
IConfigurationListener
onConfigurationSuccess
in interface IConfigurationListener
IConfigurationListener.onConfigurationSuccess(org.testng.ITestResult)
protected void generateReport(ITestContext context)
static java.lang.String formattedTime()
private void createElementFromTestResults(XMLStringBuffer document, java.util.Collection<ITestResult> results)
private void createElementFromIgnoredTests(XMLStringBuffer doc, ITestContext context)
private java.util.Properties getPropertiesFor(ITestNGMethod method, long elapsedTimeMillis)
private java.util.Set<java.lang.String> getPackages(ITestContext context)
private void createElement(XMLStringBuffer doc, ITestResult tr)
private void createFailureElement(XMLStringBuffer doc, ITestResult tr)
private void createSkipElement(XMLStringBuffer doc)
private java.lang.String encodeAttr(java.lang.String attr)
private java.lang.String replaceAmpersand(java.lang.String str, java.util.regex.Pattern pattern)
private void resetAll()
private java.lang.String generateFileName(ITestContext context)
context
- test context