Package org.testng.reporters
Class JUnitXMLReporter
java.lang.Object
org.testng.reporters.JUnitXMLReporter
- All Implemented Interfaces:
IConfigurationListener,IResultListener,IResultListener2,ITestListener,ITestNGListener
A JUnit XML report generator (replacing the original JUnitXMLReporter that was based on XML
APIs).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Patternprivate static final Patternprivate static final Patternprivate Queue<ITestResult> private Queue<ITestResult> private intprivate intprivate static final Patternprivate static final Pattern -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoked before a configuration method is invoked.private voidcreateElement(XMLStringBuffer doc, ITestResult tr) private voidcreateElementFromIgnoredTests(XMLStringBuffer doc, ITestContext context) private voidcreateElementFromTestResults(XMLStringBuffer document, Collection<ITestResult> results) private voidprivate voidprivate StringencodeAttr(String attr) (package private) static Stringprivate StringgenerateFileName(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 voidgenerateReport(ITestContext context) generate the XML report given what we know from all the test resultsgetPackages(ITestContext context) private PropertiesgetPropertiesFor(ITestNGMethod method, long elapsedTimeMillis) voidInvoked whenever a configuration method failed.voidInvoked whenever a configuration method was skipped.voidInvoked whenever a configuration method succeeded.voidonFinish(ITestContext context) Invoked after all the tests have run and all their Configuration methods have been called.voidonStart(ITestContext context) Invoked after the test class is instantiated and before any configuration method is called.voidInvoked each time a method fails but has been annotated with successPercentage and this failure still keeps it within the success percentage requested.voidInvoked each time a test fails.voidInvoked each time a test is skipped.voidonTestStart(ITestResult result) Invoked each time before a test will be invoked.voidInvoked each time a test succeeds.private StringreplaceAmpersand(String str, Pattern pattern) private voidresetAll()Reset all member variables for next test.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.testng.IConfigurationListener
beforeConfiguration, onConfigurationFailure, onConfigurationSkip, onConfigurationSuccessMethods inherited from interface org.testng.ITestListener
onTestFailedWithTimeout
-
Field Details
-
ENTITY
-
LESS
-
GREATER
-
SINGLE_QUOTE
-
QUOTE
-
ATTR_ESCAPES
-
m_numFailed
private int m_numFailed -
m_allTests
-
m_configIssues
-
m_fileNameMap
-
m_fileNameIncrementer
private int m_fileNameIncrementer
-
-
Constructor Details
-
JUnitXMLReporter
public JUnitXMLReporter()
-
-
Method Details
-
onTestStart
Description copied from interface:ITestListenerInvoked each time before a test will be invoked. TheITestResultis only partially filled with the references to class, method, start millis and status.- Specified by:
onTestStartin interfaceITestListener- Parameters:
result- the partially filledITestResult- See Also:
-
beforeConfiguration
Description copied from interface:IConfigurationListenerInvoked before a configuration method is invoked.- Specified by:
beforeConfigurationin interfaceIConfigurationListener- Parameters:
tr- The test result
-
onTestSuccess
Invoked each time a test succeeds.- Specified by:
onTestSuccessin interfaceITestListener- Parameters:
tr-ITestResultcontaining information about the run test- See Also:
-
onTestFailedButWithinSuccessPercentage
Description copied from interface:ITestListenerInvoked each time a method fails but has been annotated with successPercentage and this failure still keeps it within the success percentage requested.- Specified by:
onTestFailedButWithinSuccessPercentagein interfaceITestListener- Parameters:
tr-ITestResultcontaining information about the run test- See Also:
-
onTestFailure
Invoked each time a test fails.- Specified by:
onTestFailurein interfaceITestListener- Parameters:
tr-ITestResultcontaining information about the run test- See Also:
-
onTestSkipped
Invoked each time a test is skipped.- Specified by:
onTestSkippedin interfaceITestListener- Parameters:
tr-ITestResultcontaining information about the run test- See Also:
-
onStart
Invoked after the test class is instantiated and before any configuration method is called.- Specified by:
onStartin interfaceITestListener- Parameters:
context- The test context
-
onFinish
Invoked after all the tests have run and all their Configuration methods have been called.- Specified by:
onFinishin interfaceITestListener- Parameters:
context- The test context
-
onConfigurationFailure
Description copied from interface:IConfigurationListenerInvoked whenever a configuration method failed.- Specified by:
onConfigurationFailurein interfaceIConfigurationListener- Parameters:
itr- The test result- See Also:
-
onConfigurationSkip
Description copied from interface:IConfigurationListenerInvoked whenever a configuration method was skipped.- Specified by:
onConfigurationSkipin interfaceIConfigurationListener- Parameters:
itr- The test result- See Also:
-
onConfigurationSuccess
Description copied from interface:IConfigurationListenerInvoked whenever a configuration method succeeded.- Specified by:
onConfigurationSuccessin interfaceIConfigurationListener- Parameters:
itr- The test result- See Also:
-
generateReport
generate the XML report given what we know from all the test results- Parameters:
context- The test context
-
formattedTime
-
createElementFromTestResults
private void createElementFromTestResults(XMLStringBuffer document, Collection<ITestResult> results) -
createElementFromIgnoredTests
-
getPropertiesFor
-
getPackages
-
createElement
-
createFailureElement
-
createSkipElement
-
encodeAttr
-
replaceAmpersand
-
resetAll
private void resetAll()Reset all member variables for next test. -
generateFileName
This method guarantees unique file names for reports.
Also, this will guarantee that the old reports are overwritten when tests are run again.- Parameters:
context- test context- Returns:
- unique name for the file associated with this test context.
-