/// <summary> /// Initializes the reporting by setting the file-path and test DisplayOrder /// </summary> /// <param name="FilePath">Path of the file, in .htm or .html format</param> /// <param name="ReplaceExisting">Setting to overwrite (true) the existing file or append (false) to it</param> /// <param name="DisplayOrder">Determines the order in which your tests will be displayed</param> public ExtentReports(string FilePath, bool ReplaceExisting, DisplayOrder DisplayOrder = DisplayOrder.OldestFirst) { reportInstance = new ReportInstance(); reportInstance.Initialize(FilePath, ReplaceExisting, DisplayOrder); systemInfo = new SystemInfo(); }
internal void WriteAllResources(List<ExtentTest> TestList, SystemInfo SystemInfo) { if (terminated) { throw new IOException("Stream closed"); } if (SystemInfo != null) UpdateSystemInfo(SystemInfo.GetInfo()); if (testSource == "") return; runInfo.EndedTime = DateTime.Now; UpdateCategoryList(); UpdateSuiteExecutionTime(); UpdateMediaList(); if (this.displayOrder == DisplayOrder.OldestFirst) { lock (sourcelock) { extentSource = SourceBuilder.Build(extentSource, new string[] { ExtentFlag.GetPlaceHolder("test"), ExtentFlag.GetPlaceHolder("quickTestSummary") }, new string[] { testSource + ExtentFlag.GetPlaceHolder("test"), quickSummarySource + ExtentFlag.GetPlaceHolder("quickTestSummary") }); } } else { lock (sourcelock) { extentSource = SourceBuilder.Build(extentSource, new string[] { ExtentFlag.GetPlaceHolder("test"), ExtentFlag.GetPlaceHolder("quickTestSummary") }, new string[] { ExtentFlag.GetPlaceHolder("test") + testSource, ExtentFlag.GetPlaceHolder("quickTestSummary") + quickSummarySource }); } } using (var file = new StreamWriter(filePath)) { TextWriter.Synchronized(file).WriteLine(extentSource); } testSource = ""; quickSummarySource = ""; }