我正在使用带有 selenium / C# 的 Extent Reports V3,我刚刚升级到 V4。以前每次运行都会根据日期戳/班级名称/时间戳给我一个独特的报告。但是,在迁移到 V4 之后,它总是将所有内容放在一个名为“index”的文件和一个名为“dashboard”的单独文件下,该文件位于另一个文件之上,用于导航目的。
这是我开始报告的代码:
htmlReporter = new ExtentHtmlReporter($"C:\\Test-Results\\" + dateStamp + "\\" + TestClassName + " " + timeStamp + ".html");
extent = new ExtentReports();
extent.AttachReporter(htmlReporter);
extent.AddSystemInfo("Host Name", "Extent Framework");
extent.AddSystemInfo("Environment", "Local Machine");
extent.AddSystemInfo("User Name", "MyName");
htmlReporter.LoadConfig(CurrentDirectory + "\\extent-config.xml");
现在,每次我运行测试时,它都会用新的测试结果覆盖现有的索引文件,而不是附加我当前的结果或给我一个唯一的索引文件。如果需要,我可以提供有关如何开始报告/创建测试所需的任何其他信息,但现在这是我的测试文件中的内容:
[ClassInitialize()]
public static void MyClassInitialize(TestContext testContext)
{
report.startReport("Report Name");
}
[ClassCleanup()]
public static void MyClassCleanup()
{
report.Flush();
}
[TestInitialize()]
public void MyTestInitialize()
{
string name = TestContext.TestName;
report.CreateTest(name);
}