Customize TestNG Emailable Report
Nightly builds need to be daily supervised by the dev team in your organization so that if you summarise failures. In this story, we are going to create a readable HTML report which helps us to catch bugs of newly deployed versions using TestNG IReport listener.
The above 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 create a new stage to send this report by Email to the dev team.
Now I’m sharing the java listener for generating the HTML report with test results.
Once you add this listener to your java automation project, you should define it in 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 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’
}
}
}
Happy Testing 😊