-->

报告范围3.0.2版本 - AppendExisting(Extent Reports versi

2019-10-29 22:38发布

下面是我想使用所有测试追加到单个报告的代码。 然而,最新的测试是更换所有旧的测试报告。 因此,它不是追加到某种原因一个报告。 能否请你帮我在这里?

var htmlReporter = new ExtentHtmlReporter(ResourcesConfig.ReportPath);
            extent = new ExtentReports();
            extent.AttachReporter(htmlReporter);
            htmlReporter.LoadConfig(ResourcesConfig.ReportXMLPath);
            **htmlReporter.AppendExisting = true;**

Answer 1:

我有很多的麻烦,这个问题,以及文档没有太多解释。 我有一个名为ReportCreation一个方法,它运行的每一个测试案例,并在该方法中,我有以下几点:

public static ExtentReports ReportCreation(){
    System.out.println(extent);
    if (extent == null) {
        extent = new ExtentReports();
        htmlReports = new ExtentHtmlReporter(fileName+ n + "\\extentReportFile.html");
        htmlReports.config().setReportName("Pre release Smoke test");
        htmlReports.config().setTheme(Theme.STANDARD);
        htmlReports.config().setTestViewChartLocation(ChartLocation.BOTTOM);
        extent.attachReporter(htmlReports);
    }
    else {
        htmlReports = new ExtentHtmlReporter(fileName+ n+ "\\extentReportFile.html");
        htmlReports.setAppendExisting(true);
        extent.attachReporter(htmlReports);
    }
    return extent;
}

因此,在运行第一单元测试时,它会创建HTML报告,但第二个单元测试可以看到,该报告已经产生,因此使用现有的一个。

所以,它去到不同的报表在每次运行时我已经创建了一个随机数发生器

public static Random rand = new Random();
    public static int n = rand.nextInt(10000)+1;


文章来源: Extent Reports version 3.0.2 - AppendExisting