The below article describes the process of how we can generate a customized HTML Report from the JUnit Report XML in your CI/CD Pipeline. We have taken Jenkins CI Pipeline as an example here. However, the process should be fairly similar for any other CI System as long as it supports Unix Shell/Powershell script.


Obtaining the JUnit Report

We can generate a JUnit Report for the Testsigma Test Results in three ways:


1.) First, as mentioned above, generated by the Testsigma Test Plan Run Plugin(Jenkins)

1.1 Testsigma Test Plan run plugin - Jenkins


In the case of the Jenkins Pipeline, the JUnit report is auto-generated in the workspace in the specified path when you trigger the Test Plan using the Testsigma Test Plan Plugin.


2.) Downloading from the Test Results Page

2.1 Testsigma Test Result page - Export as JUnit XML


3.) Using the REST API for JUnit Reports:


curl --silent -H "Authorization:Bearer $TESTSIGMA_API_KEY"\
 -H "Accept: application/xml" \
 -H "content-type:application/json" \
 -X GET https://app.testsigma.com/api/v1/reports/junit/$RUN_ID \
 --output <REPORTS_DIR_PATH>/junit_report.xml


Transforming the XML to HTML using XSLT Stylesheet

We can get a customized HTML report from the JUnit report XML. This is done using XSL Transformation of the XML file to generate an HTML file using an XSLT Stylesheet as a template. A Sample XSLT Stylesheet is provided below and can be used to convert the JUnit XML report to an HTML File. You can also customize the XSLT Stylesheet to generate a report in the format you prefer.

Click to download the XSLT Template file



Mac/Linux

The built-in `xsltproc` utility can be used to transform the JUnit XML file to a specific HTML File format. You can customize the XSLT Stylesheet as per your convenience to style the HTML File.

xsltproc junit-report.xml stylesheet.xslt > testsigma-report.html


Windows

The Windows method is not as straightforward as the Unix method since the 'xsltproc' utility is not available in Windows. We will be using a Powershell Script in this case. The below git repo contains all the details regarding that.

https://github.com/renjujose-testsigma/Xml2HtmlPlugin


Integrating the XML 2 HTML conversation in Jenkins Pipeline

If we have added the Testsigma Test Plan Run Plugin in your Jenkins Pipeline, the JUnit report would be generated in the path specified in the plugin step (Image 1.1)


After that step, we just need to add one more Build Step to run the XML 2 HTML Transformation either using xsltproc(Unix) or Powershell Script(Windows)