【问题标题】:Extent Reports version 3.0.2 - AppendExisting范围报告版本 3.0.2 - AppendExisting
【发布时间】:2018-06-30 13:04:17
【问题描述】:

下面是我试图用来将所有测试附加到单个报告的代码。然而,最新的测试正在取代所有旧的测试报告。因此,由于某种原因,它没有附加到单个报告中。你能帮帮我吗?

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

【问题讨论】:

  • 该属性没有实现。 C# 绑定不支持 AppendExisting。
  • 这将在何时实施有任何更新吗?

标签: c# .net append extentreports


【解决方案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;

【讨论】:

  • 我已经用Java编写了我的代码,希望你可以用它来翻译成c#
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-25
相关资源
最近更新 更多