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.
Это класс диспетчера экстентов, который содержит путь и другие специальные учетные данные
public static ExtentHtmlReporter htmlReporter;public static 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