public void Report(string title, string message, ReporterTestInfo.TestStatus status, ReportElementType type) { ReportElement element = new ReportElement(); if (null == testDetails) { Console.WriteLine("HTML reporter was not initiliazed propertly. No reports would be created."); return; } testDetails.AddReportElement(element); element.title = title; element.message = message; element.time = DateTime.Now.ToString("HH:mm:ss"); element.status = status.ToString(); element.type = type.ToString(); if (type == ReportElementType.lnk || type == ReportElementType.img) { if (File.Exists(message)) { string fileName = FileWasAdded(testDetails, message); if (fileName != null) { element.message = fileName; } } } TestDetailsWereAdded(testDetails); }
private void UpdateLevelElementStatuses(ReportElement element) { if (null == levelElementBuffer) { // No level has been started return; } if (null == element || null == element.type) { return; } if (element.status.Equals(ReporterTestInfo.TestStatus.success.ToString())) { // Nothing to do } ReporterTestInfo.TestStatus elementStatus = (ReporterTestInfo.TestStatus)Enum.Parse(typeof(ReporterTestInfo.TestStatus), element.status); foreach (ReportElement currElement in levelElementBuffer) { ReporterTestInfo.TestStatus currElementStatus = (ReporterTestInfo.TestStatus)Enum.Parse(typeof(ReporterTestInfo.TestStatus), currElement.status); if (elementStatus > currElementStatus) { currElement.status = elementStatus.ToString(); } } }
public void Report(string title, string message, ReporterTestInfo.TestStatus status, ReportElementType type) { foreach (IReporter reporter in reporters) { lock (syncRoot) { reporter.Report(title, message, status, type); } } }
public void Report(string title, string message, ReporterTestInfo.TestStatus status, ReportElementType type) { ReportElement element = new ReportElement(); if (null == testDetails) { Console.WriteLine("HTML reporter was not initiliazed propertly. No reports would be created."); return; } element.title = title; element.message = message; element.time = DateTime.Now.ToString("HH:mm:ss"); element.status = status.ToString(); element.type = type.ToString(); testDetails.AddReportElement(element); if (type == ReportElementType.lnk || type == ReportElementType.img) { if (File.Exists(message)) { string fileName = FileWasAdded(testDetails, message); if (fileName != null) { element.message = fileName; } } } // The stopwatch is an important mechanism that helps when test is creating a large number of message in short time intervals. if (!stopwatch.IsRunning) { stopwatch.Start(); } else { if (stopwatch.ElapsedMilliseconds <= 100) { return; } } stopwatch.Restart(); TestDetailsWereAdded(testDetails); }
public void Report(string title, string message, ReporterTestInfo.TestStatus status, ReportElementType type) { ReportElement element = new ReportElement(); if (null == testDetails) { Console.WriteLine("HTML reporter was not initiliazed propertly. No reports would be created."); return; } testDetails.AddReportElement(element); element.title = title; element.message = message; element.time = DateTime.Now.ToString("HH:mm:ss"); element.status = status.ToString(); element.type = type.ToString(); if (type == ReportElementType.lnk || type == ReportElementType.img) { if (File.Exists(message)) { //This is a link to a file. Let's copy it to the report folder CreateTestFolderIfNotExists(); try { string fileName = Path.GetFileName(message); string fileDestination = testFolder + @"\" + fileName; System.IO.File.Copy(message, fileDestination, true); //We need that the link would be to the file in the report folder element.message = fileName; } catch (IOException e) { Console.WriteLine("Failed adding file to the report due to " + e.Message); } } } TestToFile(); }
public void Report(string title, string message, ReporterTestInfo.TestStatus status) { Report(title, message, status, ReportElementType.regular); }
public void Report(string title, string message, ReporterTestInfo.TestStatus status, ReportElementType type) { failureReason = title; }