-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
private int currentScenarioNumber = 0;
private int currentScreenshotNumber = 0;
private ExtentTest currentTestReport;
private ExtentReports extentReports;
private string currentStep;
private void InitExtentReports()
{
try
{
if (extentReports == null)
{
// Initialize a new instance per test execution
string reportPath = GetExtentReportsPath();
string jsonPath = GetExtentJsonPath();
// Ensure we don't delete existing reports on rerun
if (!File.Exists(reportPath))
{
Directory.CreateDirectory(Path.GetDirectoryName(reportPath));
}
var sparkReporter = new ExtentSparkReporter(GetExtentReportsPath());
var jsonFormatter = new ExtentJsonFormatter(jsonPath);
extentReports = new ExtentReports();
// If JSON file exists, load previous data to avoid overwriting
if (File.Exists(jsonPath))
{
extentReports.CreateDomainFromJsonArchive(jsonPath);
}
extentReports.AttachReporter(jsonFormatter, sparkReporter);
// Add system information
extentReports.AddSystemInfo("Machine Name", Environment.MachineName);
extentReports.AddSystemInfo("Logged In User", Environment.UserName);
extentReports.AddSystemInfo("Operating System", Environment.OSVersion.ToString());
extentReports.AddSystemInfo("Domain", "CS");
}
// Start a new test
if (currentTestReport == null)
{
currentTestReport = extentReports.CreateTest(TestContext.CurrentContext.Test.Name);
currentTestReport.Model.Info.Add("Module Name", TestContext.CurrentContext.Test.FullName.Split('.')[2]);
}
}
catch (System.Exception exception)
{
currentTestReport = null;
}
}
Metadata
Metadata
Assignees
Labels
No labels