即使任何一个子节点失败,测试也通过(在扩展报告中)

时间:2021-06-04 18:06:52

标签: selenium-webdriver testng

我已经创建了一个测试。 我为相同的测试创建了一个节点。 当任何节点失败时,测试状态通过。 注意:我除外,当任何节点失败时,时间测试状态应该失败。

samplereport.html

`public class BaseTest {    
public static ExtentHtmlReporter htmlReporter;
public static ExtentReports extent;
public static ExtentTest test;
@BeforeSuite
public void setUp()
{
    htmlReporter = new ExtentHtmlReporter("sampleReport.html");
    extent = new ExtentReports();
    extent.attachReporter(htmlReporter);    
}
@AfterMethod
public void getResult(ITestResult result,ITestContext context)
{
    String testre =  (String) context.getAttribute("testpf");
    System.out.println("testre:"+testre);
    if(testre=="FAIL")
    {
        result.setStatus(ITestResult.FAILURE);
    }
    if(result.getStatus()==ITestResult.FAILURE){
        test.fail(MarkupHelper.createLabel(result.getName() + " Test case Failed", ExtentColor.RED));
    }
    else if (result.getStatus()==ITestResult.SUCCESS){
        test.pass(MarkupHelper.createLabel(result.getName() + " Test case Passed", ExtentColor.GREEN));
    }
    else {
        test.skip(MarkupHelper.createLabel(result.getName() + " Test case Passed", ExtentColor.YELLOW));
    }
}
@AfterSuite
public void tearDown()
{
    extent.flush(); 
}

}`

0 个答案:

没有答案
相关问题