问题
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