1
votes

I want to run a custom method at the end of all the test suites execution whether successful or fail. So when testNG outputs

Tests run: 6, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 80.718 sec <<< FAILURE! - in TestSuite

After this suppose i ran 2 IT suites with 3 test methods each in them. So at the end of running all 6 cases, i want to run some custom method. How can i do that? i tried implementing custom IExecutionListener and IReporter, but both of them run once per suite. So for my 2 IT classes, i get them executed twice. Can anyone suggest the way to execute one callback per all the suites run?

2

2 Answers

4
votes

even though the javadocs say onFinish of IsuiteListener should execute once per all the suites run but i saw it getting executed multiple times. so i used IExecutionListener. below is the code i used.

public class MyReporter implements IExecutionListener {


@Override
public void onExecutionStart() {

}

@Override
public void onExecutionFinish() {

    ReportDownloadUtil.downloadReport();
}



}
1
votes

Try onFinish() in ISuiteListener interface. As per documentation it runs after all suites are ran. See here