我如何获取ExtentReport-cucumber报告实例?

时间:2018-11-28 10:36:59

标签: java cucumber testng extentreports

我正在使用tesng,extent-report和黄瓜整合在一起来构建新的自动化基础架构。 使用以下代码。

@CucumberOptions(strict= false,
                    plugin = {"pretty" ,"html:test-output/cucumber",
                            "com.vimalselvam.cucumber.listener.ExtentCucumberFormatter:",
                            "json:test-output/cucumber/cucumber.json", "pretty:test-output/cucumber/cucumber-pretty.txt",
                            "usage:test-output/cucumber/cucumber-usage.json", "junit:test-output/cucumber/cucumber-results.xml"
                            ,"com.cucumber.listener.ExtentCucumberFormatter:test-output/cucumber/cucumber-extent-reports/report.html"}
                        // , glue = {"@User"}
                          , monochrome = true)
public abstract class SROTestInfra  extends AbstractTestNGCucumberTests{
    PageFactory pageFactory = new PageFactory();
    protected WebDriver driver;


}

我正在尝试报告实例以添加信息消息,但reprot访问控制仅适用于程序包,如此开放源代码所示。

public class ExtentCucumberFormatter implements Reporter, Formatter {
  /* some code
     ****************
     ****************
 */

    private static void setExtentHtmlReport(ExtentHtmlReporter htmlReport) {
        htmlReporterThreadLocal.set(htmlReport);
    }

    static ExtentHtmlReporter getExtentHtmlReport() {
        return htmlReporterThreadLocal.get();
    }

    private static void setExtentReport(ExtentReports extentReports) {
        reportsThreadLocal.set(extentReports);
    }

    static ExtentReports getExtentReport() {
        return reportsThreadLocal.get();
    }
}

any help please.

1 个答案:

答案 0 :(得分:1)

您可以通过com.vimalselvam.cucumber.listener.Reporter类获取报告程序实例。有关更多信息,请参见:https://github.com/email2vimalraj/CucumberExtentReporter/blob/master/src/main/java/com/vimalselvam/cucumber/listener/Reporter.java#L29