微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在使用dependsOnGroups时在范围报告3.1.5中显示SKIPPED测试用例

如何解决如何在使用dependsOnGroups时在范围报告3.1.5中显示SKIPPED测试用例

我为此创建了单独的侦听器类,如下所示:

public class TestListeners implements ITestListener {

    @Override
    public void onTestSkipped(ITestResult result) {

        System.out.println("The name of the testcase Skipped is :"
                + result.getName());
        BaseClass.test1.log(Status.INFO,"The name of the testcase Skipped is :" + result.getName());
        BaseClass.test1.log(Status.SKIP,MarkupHelper.createLabel(result.getName(),ExtentColor.YELLOW));
        BaseClass.test1.log(Status.SKIP,result.getThrowable());
        BaseClass.extent.flush();
    }

    @Override
    public void onTestFailedButWithinSuccesspercentage(ITestResult result) {
        // Todo Auto-generated method stub

    }
}

此后,我在我的基类中使用了@Listeners(TestListeners.class)。 我的情况是,我必须基于类A中存在的测试用例1的结果来跳过类B中存在的测试用例2,并且我同样使用的是DependsOnGroups。

现在一切正常,但是跳过的测试用例在扩展区报告中不可见,而是仅在Eclipse IDE控制台报告中可见。

我还在添加我的基类代码。以防万一,

@Listeners(TestListeners.class)
public class BaseClass {

    public static ExtentHtmlReporter htmlReporter;
    public static ExtentReports extent;

    public static ExtentTest test1;

    public static WebDriver driver;

    
    @BeforeSuite
    public static void setup() throws InterruptedException,IOException {

        

        htmlReporter = new ExtentHtmlReporter(System.getProperty("user.dir")
                + "/Report/RegressionSuit_" + util.getFileExtension()
                + ".html");
        extent = new ExtentReports();
        extent.attachReporter(htmlReporter);

        htmlReporter.config().setChartVisibilityOnopen(true);
        htmlReporter.config().setDocumentTitle(
                "AutomationTesting.in Demo Report");
        htmlReporter.config().setReportName("RegressionSuit");
        htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
        htmlReporter.config().setTheme(Theme.STANDARD);

    }

    @AfterMethod
    public void getResult(ITestResult result) {

        if (result.getStatus() == ITestResult.FAILURE) {
            test1.log(Status.FAIL,MarkupHelper.createLabel(result.getName()
                    + " :Test case Failed due to below issues:",ExtentColor.RED));
            test1.log(Status.FAIL,result.getThrowable());

        } else if (result.getStatus() == ITestResult.SUCCESS) {
            test1.log(
                    Status.PASS,MarkupHelper.createLabel(result.getName()
                            + " :Test Case PASSED",ExtentColor.GREEN));

        } else if (result.getStatus() == ITestResult.SKIP) {
            test1.log(
                    Status.SKIP,MarkupHelper.createLabel(result.getName()
                            + " :Test Case SKIPPED ",ExtentColor.YELLOW));
        }
    }

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

    }

}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。