0

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.

swilliz
  • 13
  • 4
  • I dont think anything exists right now. But I think I can build something which would work for you. Hang in there till this weekend. I should be able to get something out by this weekend. – Krishnan Mahadevan Jul 28 '17 at 04:07
  • @KrishnanMahadevan that would be much appreciated! – swilliz Jul 28 '17 at 23:52
  • Hi @KrishnanMahadevan I am unable to get output for xml configuration files formatted like: ` ` – swilliz Aug 07 '17 at 17:45
  • @KrishnanMahadevan ` – swilliz Aug 07 '17 at 17:50
  • Not sure what you mean by I cant get output. What xml file is this ? It looks to me that this is a TestNG suite xml file. Wasnt your question around a JUnit xml file for test results which complies with Apache Ant JUnit XML Schema ? – Krishnan Mahadevan Aug 08 '17 at 02:10
  • Hi @KrishnanMahadevan, I would like to create junit style outputs from running TestNG suite files from a maven project. When I apply the listener to the maven project the output is created as expected for some of the TestNG suites; however, for suites formatted like the above examples, the output is not created. It may be an issue on my code and not yours though. I am not sure because of how your listener does work for me in some cases. – swilliz Aug 08 '17 at 20:41
  • I guess that would have to be taken offline as a separate question or perhaps you can log an issue in my library and include all information including some sample code which can be used to reproduce the problem. Since its working for some of your suites, I believe that this question can be closed off. Please accept my answer – Krishnan Mahadevan Aug 09 '17 at 03:07
  • @KrishnanMahadevan ok. Thanks for the work you put it! – swilliz Aug 09 '17 at 03:35

1 Answers1

1

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

Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66