Reputation: 853
In my @AfterSuite
annotation, I am trying to generate Jasper report that takes the testng-results.xml
as input. But, the issue here is, the testng-results.xml
gets generated only after executing @AfterSuite
annotation. I would like to know if it is possible to generate the test results before running @AfterSuite
annotation. Any help/suggestion is appreciated.
I know there are some answers related to this question here. But i did not found an exact way to do it.
Upvotes: 1
Views: 469
Reputation: 14746
The file testng-results.xml
is generated by the TestNG's built-in reporter org.testng.reporters.XMLReporter
. This reporter is kicked off only at the reporting phase (i.e., only after all the suites have run to completion).
So there's no way that this file can be generated before the @AfterSuite
annotated method runs to completion.
You could instead build your logic of constructing your jasper based reports via the listener org.testng.IExecutionListener
in its onExecutionFinish()
method.
This listener would get called after the reporting phase wherein all the reports have been generated.
The other option is you do the following:
org.testng.reporters.XMLReporter
<properties>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
</properties>
@Listeners
annotation (or)<listeners>
tag (or)Upvotes: 3