How can I append existing reports in ExtentReports 4

大城市里の小女人 提交于 2019-12-11 16:28:23

问题


I have observed that, reports get override for every run, how can I append the reports with previous reports according to their timestamp in my TestNG java project


回答1:


I just updated to Extent reports Version 4 and noticed that they now create three files index.html, dashboard.html and tag.html. Looking at there code they no longer support creating your own filename.html. If you use the V3 reporter you can do this.

I have a TestSetup Method that takes a namespaceName as input and create a folder and result file under the folder. If you use a timestamp you will get a new file every time

Here is my method

public static void TestSetup(string nameSpaceName, string className)
{
   var time = DateTime.Now.ToString("yyyy-MM-dd-h-mm-ss");
   var _resultsDir = Path.Combine(Directory.GetParent(System.AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.Parent.Parent.FullName, $@"TestResults\{nameSpaceName}");
            _screenshotDir = Path.Combine(_resultsDir, @"Screenshots");
            Directory.CreateDirectory(_screenshotDir)
  var _reportFile = Path.Combine(_resultsDir, $@"{nameSpaceName}_Results_{time}.html");
            var htmlReporter = new ExtentV3HtmlReporter(_reportFile);
            htmlReporter.LoadConfig(
                Path.Combine(Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.Parent.Parent.FullName, $@"<location of you Config file>\Extent-Config.xml"));

            Instance.AnalysisStrategy = AnalysisStrategy.Test;
            Instance.AttachReporter(htmlReporter);
}


来源:https://stackoverflow.com/questions/57033956/how-can-i-append-existing-reports-in-extentreports-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!