1

目前我正在使用硒测试ng和报告我正在使用extendreports框架进行报告。在我的情况一切工作正常。我面临的问题都是我的测试用例显示通过其不显示失败。硒扩展报告框架不生成失败状态

@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

+0

哪里是你@aftermethod? –

+0

我通过搜索得到了一些解决方案,但找不到下面的变量...是否有任何库我错过了... – zsbappa

+0

我将我的Aftermethod作为图像添加了 – zsbappa

回答

0

添加该代码后其解决

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

    } 
    // extent.endTest(test); 
}