I have different Test classes in different Testfiles, I want to create different Extent reports for each test files, right now only one report is generated which is overridden. I am using AventStack.ExtentReports.
这是扩展管理器类,其中包含路径和其他特定凭证
公共静态ExtentHtmlReporter htmlReporter;
公共静态ExtentReports范围;
public ExtentManager()
{
}
public static ExtentReports GetInstance()
{
if (extent == null)
{
string reportpath = "\\Reports\\Report.html";
htmlReporter = new ExtentHtmlReporter(reportpath);
htmlReporter.Configuration().Theme = Theme.Dark;
extent = new ExtentReports();
extent.AttachReporter(htmlReporter);
extent.AddSystemInfo("Host Name", "ABC");
extent.AddSystemInfo("Environment", "Test QA");
extent.AddSystemInfo("Username", "XYZ");
htmlReporter.LoadConfig("extent-config.xml"); //Get the config.xml file
}
return extent;
}
public testclass1
{
ExtentReports rep;
ExtentTest test;
public testclass()
{
rep = ExtentManager.GetInstance();
}
public void TestMethod1()
{
test = rep.CreateTest("LoginPage");
test.Log(Status.Info, "Starting test");
//My Login method to login in the app
rep.flush();
}
}
public testclass2
{
ExtentReports rep;
ExtentTest test;
public testclass()
{
rep = ExtentManager.GetInstance();
}
public void TestMethod2()
{
test = rep.CreateTest("userblock");
test.Log(Status.Info, "Starting test");
//My userblockmethod
rep.flush();
}
}
//创建一个覆盖它的报告,并给出最后执行的测试类的报告
结果-
testclass1Report.html
testclass2Report.html