How to call a method at the end of test suite

22 views
Skip to first unread message

Udaya Kumar Anem

unread,
Sep 10, 2016, 6:05:30 AM9/10/16
to Cukes
Hi all,

I have my cucumber suite which works well, but i am stuck generating HTML reports.

I need to generate HTML reports from cucumber-jvm-reporting.

This below method which converts the generated Cucumber.json file to HTML report. 

 public void generateCucumberReports()
 
{
 
File reportOutputDirectory = new File("E:\\Programming\\Cucumber\\MyProj\\Results");
 
List<String> jsonFiles = new ArrayList<>();
 jsonFiles
.add("E:\\Programming\\Cucumber\\MyProj\\target\\cucumber.json");




 
String projectName = "cucumber-jvm";
 
Configuration configuration = new Configuration(reportOutputDirectory, projectName);


 
ReportBuilder reportBuilder = new ReportBuilder(jsonFiles, configuration);
 reportBuilder
.generateReports();
 
}


This code is working fine when i run as standalone meaning, the below line generates HTML reports. So no problem in this method.
public static void main(String[] args)
{
  generateCucumberReports
();
}



but when i invoke this method in @After method, it is not generating HTML reports. So can someone help me how to invoke this after the entire suite is completed execution?
@After
 
public void tearDown()
 
{
 generateCucumberReports
();
 
}



Udaya Kumar Anem

unread,
Sep 11, 2016, 3:12:46 AM9/11/16
to Cukes

The below piece of code when added to hooks helped me:

Runtime.getRuntime().addShutdownHook(new Thread() {
            public void run() {
            objUtil.generateCucumberReports();
          
            }
        });

Thanks,
Uday
Reply all
Reply to author
Forward
0 new messages