Open xenaree opened 7 years ago
This is because a new instance is created and the last instance is overwriting all the previous runs. Can this code come from a static class instead of a new instance each time the method runs:
string reportpath = projectPath + "com.seloger.reports\\AfficherTypeProjet-"+DateTime.Now.ToString("yyyyMMdd") +".html";
_report = new ExtentReports(reportpath, true);
_report.AddSystemInfo("HostName", "Kais")
.AddSystemInfo("Environment", "PROD")
.AddSystemInfo("User Name", "Kais KHALIFA");
_report.LoadConfig(projectPath + "extentReport-config.xml");
Example:
if (_report == null)
_report = ExtentManager.Instance;
ExtentManager (http://extentreports.com/docs/versions/3/net/#helper-classes):
public class ExtentManager
{
private static readonly ExtentReports _instance = new ExtentReports();
static ExtentManager()
{
var htmlReporter = new ExtentHtmlReporter("Extent.html");
Instance.AttachReporter(htmlReporter);
}
private ExtentManager() { }
public static ExtentReports Instance
{
get
{
return _instance;
}
}
}
Thank you for your reply. Shouldn't this fix the issue? _report = new ExtentReports(reportpath, false) instead of true?
It may but I wouldn't recommend this in a parallel fashion as 2 threads writing to the same file may cause conflicts. You can make this block synchronized and it should work but a better way still is using the above approach.
Only the second TestFixture is displayed in the html report