Reputation: 31888
What's Working - We are currently using testng
emailable format and allure
to generate formatted reports for our current test execution. These are working fine with our local. The /target/report
structure can be seen in the image to depict 2 different folders for allure(/site) and testng(/surefire) reports respectively :
Trying to - While we are trying to implement a CI using Jenkins using the same steps as in our local, the tests are executed fine and the respective reports are getting generated as well.
Using TestNG plugin
and specifying the pattern **/target/surefire-reports/testng-results.xml
works just fine to display the testNG result graph.
Also using the Email ext plugin I can attach the .html reports to the mail sent to the recipients specifying the attachment field details as :
**/target/surefire-reports/emailable-report.html, **/target/surefire-reports/index.html
What doesn't work - We end up getting emails with HTML reports but these are not formatted, probably because all the CSS linked to these are left behind. Is there a way to overcome this?
Note - Have tried these:
Attaching all the .css files along with .html file in attachments but, one that's brute force and second it still doesn't work.
One way also is to scp
the report (/target) directory to another host from Jenkins instance and share the path of the reports on that machine over the email notification and get the formatted reports shared. But then this needs an additional resource and dependency on it, that we would want to avoid.
While posting this, I see an HTML publisher plugin that seems to be doing something similar. Tried installing the same and use it. But I am assuming since we are using Jenkins 2.6
and the plugin note reads
Starting in versions 1.625.3 and 1.641, Jenkins restricted what kind of content could be displayed when serving static files. This can impact how HTML files archived using this plugin are displayed. See Configuring Content Security Policy for more information.
We are not getting the option to Publish HTML Reports
in the post build actions.
Any suggestions are more than welcome and please do ask for any more information required over this.
Edit : Adding to the Note 2 above, the Jenkins instances used in our setup are docker slaves, apparently making the reports or targets generated not being persistent.
Upvotes: 0
Views: 2829
Reputation: 14746
Here's what you can consider doing.
Option 1
PS : Currently implementations of IExecutionListener are invoked "before" the report generation phase. I have changed this as part of this commit. So if you would like to go ahead with this approach then you might want to wait till TestNG goes out with a new release (should happen in a couple of days )
Option 2
public class ChainedReporter implements IReporter {
private List<IReporter> reporters = new ArrayList<>;
public ChainedReporter() {
reporters.add(new FooReporter() );//Here FooReporter is a custom reporter. Replace it with yours.
reporters.add(new BarReporter() );//Here BarReporter is a custom reporter. Replace it with yours.
}
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
for (IReporter reporter : reporters) {
reporter.generateReport(xmlSuites, suites, outputDirectory);
}
//By now we have ensured that all the reporting logic has been triggered and we have reports generated.
zipReports(); // This method would take care of creating zipped files of all the reports.
emailReports(); // This emthod would take care of emailing the actual reports.
}
}
Upvotes: 1