Reputation: 11
HI I am unable to get the reports. I am not facing any kind of errors but reports are not generating.
public class Listners extends TestListenerAdapter{
public ExtentHtmlReporter htmlReporter;
public ExtentReports extent;
public ExtentTest test;
public void onStart (ITestContext testContext)
{
htmlReporter = new ExtentHtmlReporter(System.getProperty("user.dir")+"/test-output/myReport.html");
htmlReporter.config().setDocumentTitle("Automation Report");
htmlReporter.config().setReportName("Rest API Testing Report");
extent = new ExtentReports();
public void onTestSuccess(ITestResult testResult)
{
test = extent.createTest(testResult.getName());
test.log(Status.PASS, "Test Case Pass is --" +testResult.getName());
}
public void onTestFailure(ITestResult testResult)
{
test = extent.createTest(testResult.getName());
test.log(Status.FAIL, "Test Case Failed is --" +testResult.getName());
test.log(Status.FAIL, "Test Case Failed is --" +testResult.getThrowable());
}
public void onTestSkipped(ITestResult testResult)
{
test = extent.createTest(testResult.getName());
test.log(Status.SKIP, "Test Case Skipped is --" +testResult.getName());
}
public void onTestFlush(ITestContext testContext)
{
extent.flush();
}
Upvotes: 1
Views: 238
Reputation: 46
If I understood the question, you just should marked your test class by @Listeners annotation and put your Listener class into this annotation.
@Listeners([your listener class name].class)
public void [your test class name] {
/*
*
* some tests
*
*/
}
Upvotes: 0