I want to get latest emailable-report in mail rather than previous
last emailable-report.. How can I do that?
I think..you're sending mail in your @aftersuite
.You're getting previous test emailable-report because the test is currently running and only when it finishes reports will be generated.
I will suggest you to use a continuous Integration server like jenkins because it gives sending emails as a post build option or build tool like Maven or ant to run your tests, then have a post test event to email the results.Maven also provides many plugins to automatically send mails after test execution like Postman mail plugin
Another solution : If you are not willing to use a continuous Integration server(jenkins) or maven or ant
TestNG IReporter listener
Create your own CustomReport by implementing your class to IReporter
Interface.This interface has only one method to implement generateReport. This method has all the information of a complete test execution in the List and we can generate report using it.
public class CustomReporter implements IReporter{
@Override
public void generateReport(List<XmlSuite> arg0, List<ISuite> arg1,
String outputDirectory) {
for (ISuite iSuite : arg1) {
Map<String,ISuiteResult> results = iSuite.getResults();
Set<String> keys = results.keySet();
for (String key : keys) {
ITestContext context = results.get(key).getTestContext();
}
}
}
}
Hope this helps you...Kindly get back if you need any further help