You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Time taken showing incorrect after adding multiple testcases in same extent report using json #236
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;
}
if (log.Details != null)
{
var testObj = extentTest.Log(log.Status, log.Details, media);
testObj.Test.Logs.Last().Timestamp = log.Timestamp; // <- this line will copy the original timestamp
}
The last one change is this replacement. Looks like they are interchangeable, but the latter one is public and the first protected. _extent.UsingNaturalConf = false;
with _extent.UseNaturalTime = false;
Activity
Thowk commentedon Feb 26, 2026
I noticed the same issue. Log timestamp is not transferred properly from the source JSON.
Quick fix is to take the
TestEntityParser.csand add one more line to the parser:extentreports-csharp/ExtentReports/Model/Convert/TestEntityParser.cs
Lines 59 to 62 in 7a7c0c5
The last one change is this replacement. Looks like they are interchangeable, but the latter one is public and the first protected.
_extent.UsingNaturalConf = false;with
_extent.UseNaturalTime = false;