seleniumtestingselenium-webdriverselenium-extent-report

Selenium extent reports framework not generating failed status


Currently, I am using Selenium TestNG and Extent Reports framework for reporting. I am facing a problem where all are my test cases are showing Pass and not showing Fail.

@BeforeTest
public void setUp()
{
    //where we need to generate the report
    htmlReporter = new ExtentHtmlReporter(System.getProperty("user.dir")+"/test-output/MyReport.html");
    extent = new ExtentReports();
    extent.attachReporter(htmlReporter);

    // Set our document title, theme etc..
    htmlReporter.config().setDocumentTitle("My Test Report");
    htmlReporter.config().setReportName("Test Report");
    htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
    htmlReporter.config().setTheme(Theme.DARK);
}

@Test
public void On_Page_IM() throws InterruptedException {
    test = extent.createTest("On_Page_IM");
    wd.manage().window().maximize();        
    Thread.sleep(10000);       
    test.log(Status.INFO,"On page intent media: Show");
}

@AfterSuite
public void tearDown()
{
    extent.flush();
    wd.quit();
}

@Aftermethod


Solution

  • After Added this code its solved

       @AfterMethod
    public void getResult(ITestResult result)
    {
        if(result.getStatus()==ITestResult.FAILURE)
        {
            test.log(Status.FAIL, result.getThrowable());
    
        }
       // extent.endTest(test);
    }