How to Customize TestNG Emailable Report ?

TestNG emailable reports are too bad and unreadable, in this post I'll illustrate the we send and improve the reports using TestNG IReport listener.


The report includes the number of passed, failed, and skipped tests with execution times and test names.
If you are using a CI tool such as Jenkins pipeline, you can add a new stage for emailing this report to the dev team. Nightly builds need to be daily supervised by the dev team in your organization so that if you summarise failures with this readable report would be helpful to catch bugs of newly deployed versions.

Now I'm sharing the java listener for generating the HTML report with test results.

After you add this listener to your java project, you need to add it to your xml runner file like this:

<listeners>
<listener class-name="automationInfra.com.listeners.CustomizedEmailableReport">
</listener>
</listeners>

Now we back to Jenkins pipeline send email stage, in your build file add a new stage for sending generated report by email like this using emailext jenkins plugin:

stage('Email Results'){
 steps{
  script{
    emailext attachLog: false, body: '<b>Check portal results here: </b> $BUILD_URL/cucumber-       html-reports/overview-features.html <br><br><br>     ${FILE,path="/var/lib/jenkins/workspace/reports/emailable_report/emailableResults.html"}',   mimeType: 'text/html', replyTo: '', subject: "Jenkins Report: ${env.JOB_NAME}   [${env.BUILD_NUMBER}]", to: 'email@gmail.com'
  }
 }
}

The reporting integration is done now and you can run your test suite to check your integration.

Comments

Popular posts from this blog

Handling Selenium Grid Exceptions

Add customized jar as Maven Dependency