范围报告report.endTest(测试)方法? [英] Extent report report.endTest(test) method?

查看:152
本文介绍了范围报告report.endTest(测试)方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在搞乱Selenium Java Extent Reports。他们的新版本截止到10月12日,但我没有看到endTest方法。他们尚未发布v3.0.0的完整文档。大多数事情都是大致相同的用法,但endTest方法似乎不再可用。

I'm messing around with Selenium Java Extent Reports. Their new version is out as of Oct 12 but I'm not seeing the endTest method. They haven't released their full documentation for v3.0.0 yet. Most everything is about the same usage-wise but the endTest method no longer seems to be available.

有谁知道如何结束测试运行,以便可以进行多项测试显示在同一报告文件中?

Does anyone know how to end a test run so that multiple tests can be displayed in the same report file?

report = ExtentFactory.getInstance(date, time);
test = report.createTest("mytest");
test.log(Status.INFO, "test started");
// do some other stuff
report.endTest(test);  <-- this is no longer an option.

任何人都知道结束测试的新方法是什么?

Anyone know what the new way to end a test is?

我能找到的只是

report.close();

但这似乎不允许我将多个测试放入同一报告中。

but that doesn't seem to let me put multiple tests into the same report.

推荐答案

版本3完全不同 - 您现在可以决定您需要哪些记者。下面的示例同时使用Html和ExtentX:

Version 3 is quite different - you now have the ability to decide which reporters you require. The below example uses both Html and ExtentX:

ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("filePath");
ExtentXReporter extentxReporter = new ExtentXReporter("host");

ExtentReports extent = new ExtentReports();
extent.attachReporter(htmlReporter, extentxReporter);

单个测试不再需要结束,您只需要担心记录事件。下面将开始并向报告添加2个测试:

Individual tests no longer need to be ended, you only have to worry about logging events. The below will start and add 2 tests to the report:

extent.createTest("Test1").pass("pass");
extent.createTest("Test2").error("error");

写入结果文件与以前相同:

Writing to the results file is the same as before:

extent.flush();

根据您的测试运行员(我将展示如何在TestNG中使用它),您现在拥有创建测试并向其添加信息,如下所示(以下方法支持多线程):

Depending upon your test-runner (I will show how to use it with TestNG), you now have to create tests and add information to them such as below (the below approach supports multi-threading):

public class ExtentTestNGReportBuilder {

    private ThreadLocal<ExtentTest> parentTest;
    private ThreadLocal<ExtentTest> test;

    @BeforeClass
    public synchronized void beforeClass() {
        ExtentTest parent = ExtentTestManager.createTest(getClass().getName());
        parentTest.set(parent);
    }

    @BeforeMethod
    public synchronized void beforeMethod(Method method) {
        ExtentTest child = parentTest.get().createNode(method.getName());
        test.set(child);
    }

    @AfterMethod
    public synchronized void afterMethod(ITestResult result) {
        if (result.getStatus() == ITestResult.FAILURE)
            test.get().fail(result.getThrowable());
        else if (result.getStatus() == ITestResult.SKIP)
            test.get().skip(result.getThrowable());
        else
            test.get().pass("Test passed");

        ExtentManager.getExtent().flush();
    }

}

以上只是为了给你一个想法,你可以在这里找到整个代码库: https:// github。 com / anshooarora / extentreports-java / issues / 652#issuecomment-254078018

The above is just to give you an idea, you can find the entire codebase here: https://github.com/anshooarora/extentreports-java/issues/652#issuecomment-254078018

这篇关于范围报告report.endTest(测试)方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆