junittestngjenkins-pluginslistenerstestrail

Testng listener to comply with Apache Ant JUnit XML Schema


As part of a testng automation test suite I would like to automatically push results from jenkins to testrail. I currently have this plugin installed on my jenkins server: https://github.com/jenkinsci/testrail-plugin

The read me states the output must comply with the junit schema: https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd

I have reference How do I get one junit report from TestNG for all my test cases? and added

 <listeners>
    <listener class-name="org.testng.reporters.JUnitXMLReporter"></listener>
</listeners>

to my listeners; however, this does not seem to create a file in the correct format as this causes jenkins to fail with the message :

Uploading results to TestRail. Error pushing results to TestRail Posting to index.php?/api/v2/add_results_for_cases/236 returned an error! Response from TestRail is: {"error":"Field :results cannot be empty (one result is required)"} Build step 'TestRail Plugin' marked build as failure Finished: FAILURE

I am wondering if there is a different listener I should be using instead.

Thank you for the help.


Solution

  • I used the xsd file that was shared in the question to create a TestNG reporter that complies with the xsd.

    To consume this reporter, please add a dependency as below

    <dependency>
        <groupId>com.rationaleemotions</groupId>
        <artifactId>junitreport</artifactId>
        <version>1.0.0</version>
    </dependency>
    

    This reporter makes use of the service loader approach to wire in itself. So it doesn't need to be added explicitly via the <listeners> tag (or) the @Listeners annotation.

    Details can be found here