0

I just want to create an emailable template execution report by using the testng-results.xml files through JAVA or testng listeners. I have existing testng-results.xml file which I need to make it as emailable reports. Is there any way to do that. I just need some input and ideas to kick start this activity.

Any leads.

Eric Andres
  • 3,417
  • 2
  • 24
  • 40
ArrchanaMohan
  • 2,314
  • 4
  • 36
  • 84

1 Answers1

0

Use XSLT template, the most efficient and easy way to generate to any report format from xml.

In my project, we are generating different category of html reports from testng-results.xml for fast regression analysis. Also we had generated json report using xslt from testng-results.xml to see aggregate result.

We use gradle build tool to run xslt and generate report after completion of test like,

configurations{ xslt }

dependencies {
    xslt    'net.sf.saxon:saxon:8.7'
}
task generateReport << {
    File reportDir=new File("${projectDir}/HTML_Reports")
    if(reportDir.exists()){
        reportDir.deleteDir()
    }
    reportDir.mkdir()
    ant.xslt(in: "${testReportDir.absolutePath}/test/testng-results.xml",
             style: "${projectDir.absolutePath}/src/test/resources/xslt_config/emailablereport.xsl",
             out: "${reportDir.absolutePath}/index.html",
             classpath: configurations.xslt.asPath) {
            param(name: 'paramXSLT.environment', expression: "${env}")
        }

You can also run xsl in maven using this plugin

For run xsl in java program refer this post

Navarasu
  • 8,209
  • 2
  • 21
  • 32
  • Will it create a html report as look like emailable default testng report format? because I just want to generate the report in that format and handover the consolidated report to management. – ArrchanaMohan Oct 25 '18 at 04:21
  • Yes. if you have sample html, just paste it inside in xsl template and fill the dynamic data by mapping appropriate. Iterative data can be iterated based on the no of elements return by xpath. – Navarasu Oct 25 '18 at 19:14