范围报告版本3.0.2-AppendExisting [英] Extent Reports version 3.0.2 - AppendExisting

查看:83
本文介绍了范围报告版本3.0.2-AppendExisting的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我要用来将所有测试附加到单个报告中的代码。但是,最新测试将替换所有较早的测试报告。因此,由于某种原因,它不会附加到单个报告中。您可以在这里帮我吗?

Below is the code I am trying to use to append all tests to a single report. However, latest test is replacing all the older test reports. So, it's not appending to a single report for some reason. Can you please help me out here?

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


推荐答案

我对此有很多麻烦,并且文档没有太多解释。我有一个称为ReportCreation的方法,该方法针对每个测试用例运行,在该方法中,我具有以下内容:

I had a lot of trouble with this as well as the documentation doesn't explain much. I have one method called ReportCreation which runs for every test case and in that method i have the following:

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报告,但是第二个单元测试将看到该报告已经生成,因此可以使用现有的报告。

So when the first unit test is run, it will create the html report, but the second unit test will see that the report has already been generated and so use the existing one.

我创建了一个随机数生成器,以便将其转到另一个每次运行都会报告

I have created a random number generator so that it goes to a different report on every run

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

这篇关于范围报告版本3.0.2-AppendExisting的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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