public void ShouldOpenHtmlReportIfOptionIsProvided() { var mockProcess = new Mock <IWebbrowserOpener>(); var mockFileSystem = new MockFileSystem(); var options = new StrykerOptions { ReportTypeToOpen = ReportType.Html, OutputPath = Directory.GetCurrentDirectory(), ReportFileName = "mutation-report" }; var reporter = new HtmlReporter(options, mockFileSystem, processWrapper: mockProcess.Object); var mutationTree = JsonReportTestHelper.CreateProjectWith(); reporter.OnAllMutantsTested(mutationTree); var reportUri = Path.Combine(options.OutputPath, "reports", $"{options.ReportFileName}.html"); reportUri = "file://" + reportUri.Replace("\\", "/"); // Check if browser open action is invoked mockProcess.Verify(m => m.Open(reportUri)); }
public List <string> WaitForVisibilityOfAllElementTextsLocatedBy(string elementName, By byObject, List <string> itemList) { try { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(GetWaitTimeoutSeconds())); List <string> list = wait.Until(CustomExpectedConditions.VisibilityOfAllElementTextsLocatedBy(byObject, itemList)); string info = string.Format("Wait for text list to be present in element. String list: [{0}]; Element information: {1}", string.Join(", ", itemList.ToArray()), elementName); HtmlReporter.Pass(info); NLogger.Info(info); return(list); } catch (WebDriverTimeoutException ex) { var message = string.Format("Text list is not present in element as expected. String list: [{0}]; Element information: {1}", string.Join(", ", itemList.ToArray()), elementName); string screenshot = ScreenShotCapturing.TakeScreenShoot(driver, message); HtmlReporter.Fail(message, ex, screenshot); throw new ErrorHandler(message, ex); } }
public void EnterText(string elementName, By byObject, string text) { IWebElement element = null; try { element = WaitForElementToBeVisible(elementName, byObject); element.Clear(); element.SendKeys(text); string info = string.Format("Enter text [{0}] to element [{1}].", text, elementName); NLogger.Info(info); HtmlReporter.Pass(info); } catch (WebDriverException ex) { string message = string.Format("An error happens when trying to send text [{0}] to element [{1}].", elementName); ScreenShotCapturing.HighlightElement(driver, element); string screenshot = ScreenShotCapturing.TakeScreenShoot(driver, message); HtmlReporter.Fail(message, ex, screenshot); throw new ErrorHandler(message, ex); } }
public void VerifyText(string elementName, By byObject, string expected) { string actual = null; try { actual = GetText(elementName, byObject); Assert.AreEqual(expected, actual); string info = string.Format("Text of element [{0}] as expectation [{1}]", elementName, expected); NLogger.Info(info); HtmlReporter.Pass(info); } catch (AssertFailedException ex) { IWebElement element = WaitForElementToBeVisible(elementName, byObject); string message = string.Format("Verify text for element [{0}] failed. Expected [{1}] but actual [{2}]", elementName, expected, actual); ScreenShotCapturing.HighlightElement(driver, element); string screenshot = ScreenShotCapturing.TakeScreenShoot(driver, message); HtmlReporter.Fail(message, ex, screenshot); throw new ErrorHandler(message, ex); } }
public void ShouldReplacePlaceholdersInHtmlFile() { var mockProcess = new Mock <IWebbrowserOpener>(); var mockFileSystem = new MockFileSystem(); var options = new StrykerOptions { Thresholds = new Thresholds { High = 80, Low = 60, Break = 0 }, OutputPath = Directory.GetCurrentDirectory(), ReportFileName = "mutation-report" }; var reporter = new HtmlReporter(options, mockFileSystem, processWrapper: mockProcess.Object); reporter.OnAllMutantsTested(JsonReportTestHelper.CreateProjectWith()); var reportPath = Path.Combine(options.OutputPath, "reports", $"mutation-report.html"); var fileContents = mockFileSystem.GetFile(reportPath).TextContents; fileContents.ShouldNotContain("##REPORT_JS##"); fileContents.ShouldNotContain("##REPORT_TITLE##"); fileContents.ShouldNotContain("##REPORT_JSON##"); }
private void btnRaporAl_Click_1(object sender, EventArgs e) { dietToPatientDto = patientManager.GetDietToPatientDto(_hastaDetay.Id); patientToDietDto = patientManager.GetPatientToDietDto(_hastaDetay.Id); if (cmbRapor.Text == "JSON") { JsonReporter jsonReporter = new JsonReporter(); if (cmbSiralama.Text == "Önce hasta bilgisi, sonra diyet") { jsonReporter.CreateJson(patientToDietDto, "userData.json"); } else { jsonReporter.CreateJson(dietToPatientDto, "userData.json"); } } else if (cmbRapor.Text == "HTML") { HtmlReporter htmlReporter = new HtmlReporter(); if (cmbSiralama.Text == "Önce hasta bilgisi, sonra diyet") { htmlReporter.build(patientToDietDto, true); } else { htmlReporter.build(patientToDietDto, false); } } MessageBox.Show("Rapor oluşturuldu !"); this.Hide(); }
//private int _consoleWidth = 80; #endregion Fields #region Ctor private ReporterManager(string reportTitle, ReporterTypeEnum reporters) { List <IReporter> reports = new List <IReporter>(); if (!Directory.Exists(ReporterManager.DEFAULT_OUTPUT_FOLDER)) { Directory.CreateDirectory(ReporterManager.DEFAULT_OUTPUT_FOLDER); } if (!reporters.Equals(ReporterTypeEnum.Default)) { IReporter reporter; foreach (Enum value in Enum.GetValues(reporters.GetType())) { if (reporters.HasFlag(value) && value.Equals(ReporterTypeEnum.ConsoleReporter)) { reporter = new ConsoleReporter(ReporterManager.DEFAULT_OUTPUT_FOLDER); } else if (reporters.HasFlag(value) && value.Equals(ReporterTypeEnum.HtmlReporter)) { reporter = new HtmlReporter(ReporterManager.DEFAULT_OUTPUT_FOLDER); } else { reporter = null; } if (reporter != null) { reports.Add(reporter); } } } _reportManagerHandler = new ReportServiceHandler(reportTitle, ReporterManager.DEFAULT_OUTPUT_FOLDER, reports); }
public void HoverMouseAndClick(string elementName, By byObject) { IWebElement element = null; try { element = WaitForElementToBeVisible(elementName, byObject); HoverMouseOn(elementName, byObject); IJavaScriptExecutor executor = (IJavaScriptExecutor)driver; executor.ExecuteScript("arguments[0].click();", element); string info = string.Format("Hover mouse and click on element [{0}].", elementName); NLogger.Info(info); HtmlReporter.Pass(info); } catch (WebDriverException ex) { string message = string.Format("An error happens when trying to hover mouse and click element on [{0}]", elementName); ScreenShotCapturing.HighlightElement(driver, element); string screenshot = ScreenShotCapturing.TakeScreenShoot(driver, message); HtmlReporter.Fail(message, ex, screenshot); throw new ErrorHandler(message, ex); } }
public void ShouldContainJsonInHtmlReportFile() { var mockProcess = new Mock <IWebbrowserOpener>(); var mockFileSystem = new MockFileSystem(); var options = new StrykerOptions { Thresholds = new Thresholds { High = 80, Low = 60, Break = 0 }, OutputPath = Directory.GetCurrentDirectory(), ReportFileName = "mutation-report" }; var reporter = new HtmlReporter(options, mockFileSystem, processWrapper: mockProcess.Object); var mutationTree = JsonReportTestHelper.CreateProjectWith(); reporter.OnAllMutantsTested(mutationTree); var reportPath = Path.Combine(options.OutputPath, "reports", $"mutation-report.html"); var fileContents = mockFileSystem.GetFile(reportPath).TextContents; fileContents.ShouldContain(@"""thresholds"":{"); fileContents.ShouldContain(@"""high"":80"); fileContents.ShouldContain(@"""low"":60"); }
static void Main(string[] args) { InitGlobalizationEngine(Language.EN); Model model = new Model(); Device device = model.CreateDevice("Master"); SMQueue queue = model.CreateQueue("Accumulator"); UInt64 transactCounter = 1; model.Schedule((int)Events.EventGenerate, model.Random(14, 26), transactCounter); model.Schedule((int)Events.EventEnd, 480, (ulong)1e9); // Объявим переменную, в которой будем хранить номер текущего транзакта UInt64 transact = 1; // И переменную, в которй будем хранить тип текущего события Events @event = Events.EventEnd; do { (UInt64, UInt64)top = model.Cause(); // Разбираем пару на отдельные составляющие @event = (Events)top.Item1; transact = top.Item2; switch (@event) { // Алгоритм обработки события порождения заявки case Events.EventGenerate: { // Планируем сразу же событие резервирования устройства за этой заявкой model.Schedule((int)Events.EventReserve, 0, transact); // Увеличиваем счетчик транзактов transactCounter++; // Планируем поступление следующией заявки model.Schedule((int)Events.EventGenerate, model.Random(14, 26), transactCounter); break; } case Events.EventReserve: { if (device.GetState() == Device.State.Idle) { // В случае, если устройство свободно, займем его заявкой device.Reserve(transact); // Запланируем освобождение устройства model.Schedule((int)Events.EventRelease, model.Random(12, 20), transact); } else { queue.Add(transact, 0); } break; } case Events.EventRelease: { device.Release(); if (queue.Count > 0) { UInt64 transactId = queue.Dequeue(out UInt64 stage).TransactId; model.Schedule((int)Events.EventReserve, 0, transactId); } break; } case Events.EventEnd: { break; } default: { throw new Exception(); } } }while (@event != Events.EventEnd); TextReporter textReporter = new TextReporter(model); textReporter.GetReport("output.txt"); using (MdReporter mdReporter = new MdReporter(model)) { mdReporter.GetReport("output.md"); } using (HtmlReporter htmlReporter = new HtmlReporter(model)) { htmlReporter.GetReport("output.html"); } }
public override void OnSuccess(MethodExecutionArgs args) { HtmlReporter Report = new HtmlReporter(); Report.Success(((BaseSteps)args.Instance).PageName, args.Method.Name); }
static void Main(string[] args) { InitGlobalizationEngine(Language.RU); Model model = new Model(); MultiChannelDevice multiChannelDevice = model.CreateMultiChannelDevice("MultiChannel", 7); SMQueue queue = model.CreateQueue("Accumulator"); UInt64 transactCounter = 1; model.Schedule((int)Events.EventGenerate, model.Random(14, 26), transactCounter); model.Schedule((int)Events.EventEnd, 4800, (ulong)1e9); UInt64 currentTransact = 1; Events currentEvent = Events.EventEnd; do { (UInt64, UInt64)top = model.Cause(); currentEvent = (Events)top.Item1; currentTransact = top.Item2; switch (currentEvent) { case Events.EventGenerate: { model.Schedule((int)Events.EventReserve, 0, currentTransact); transactCounter++; model.Schedule((int)Events.EventGenerate, model.Random(14, 26), transactCounter); break; } case Events.EventReserve: { if (multiChannelDevice.GetState() != Device.State.Full) { multiChannelDevice.Reserve(currentTransact); model.Schedule((int)Events.EventRelease, model.Random(130, 150), currentTransact); } else { queue.Add(currentTransact, 0); } break; } case Events.EventRelease: { multiChannelDevice.Release(); if (queue.Count > 0) { UInt64 transactId = queue.Dequeue(out UInt64 stage).TransactId; model.Schedule((int)Events.EventReserve, 0, transactId); } break; } case Events.EventEnd: { break; } default: { throw new Exception(); } } }while (currentEvent != Events.EventEnd); using (HtmlReporter htmlReporter = new HtmlReporter(model)) { htmlReporter.GetReport("output.html"); } }
public void BeforeEachScenario() { var scenario = ScenarioContext.Current.ScenarioInfo; HtmlReporter.CreateNode("Scenario", scenario.Title); }
public static void AfterTestRun() { HtmlReporter.Flush(); driver.DestroyDriver(); }
static void Main(string[] args) { InitGlobalizationEngine(Language.RU); Model model = new Model(); Device processor = model.CreateDevice("Processor"); Device outputBuffer1 = model.CreateDevice("Output buffer 1"); Device outputBuffer2 = model.CreateDevice("Output buffer 2"); SMQueue inputQueue = model.CreateQueue("Input queue"); SMQueue outputQueue1 = model.CreateQueue("Output queue 1"); SMQueue outputQueue2 = model.CreateQueue("Output queue 2"); SMQueue resultQueue1 = model.CreateQueue("Total processed messages from input 1"); SMQueue resultQueue2 = model.CreateQueue("Total processed messages from input 2"); UInt64 transactCounter = 1; model.Schedule((int)Events.Incoming1, model.Random(m1 - s1, m1 + s1), transactCounter); model.Schedule((int)Events.Incoming2, model.Random(m2 - s2, m2 + s2), ++transactCounter); model.Schedule((int)Events.End, (ulong)TimeSpan.FromMinutes(24).TotalMilliseconds, (ulong)1e9); UInt64 transact = 1; Events @event = Events.End; do { (UInt64, UInt64)top = model.Cause(); @event = (Events)top.Item1; transact = top.Item2; switch (@event) { case Events.Incoming1: { if (m_currentItems1 > m_maxAvailableItems1) { // Do nothing delete item and schedule next model.Schedule((int)Events.Incoming1, model.Random(m1 - s1, m1 + s1), transactCounter); break; } m_currentItems1++; model.Schedule((int)Events.ProcessorReserve1, 0, transact); transactCounter++; model.Schedule((int)Events.Incoming1, model.Random(m1 - s1, m1 + s1), transactCounter); break; } case Events.Incoming2: { if (m_currentItems2 > m_maxAvailableItems2) { // Do nothing delete item and schedule next model.Schedule((int)Events.Incoming2, model.Random(m2 - s2, m2 + s2), transactCounter); break; } m_currentItems2++; model.Schedule((int)Events.ProcessorReserve2, 0, transact); transactCounter++; model.Schedule((int)Events.Incoming2, model.Random(m2 - s2, m2 + s2), transactCounter); break; } case Events.ProcessorReserve1: { if (processor.GetState() == Device.State.Idle) { processor.Reserve(transact); model.Schedule((int)Events.ProcessorRelease1, model.Random(T1 - T1_dop, T1 + T1_dop), transact); } else { // Stage gives info is it item from first input or second inputQueue.Add(transact, 1); } break; } case Events.ProcessorReserve2: { if (processor.GetState() == Device.State.Idle) { processor.Reserve(transact); model.Schedule((int)Events.ProcessorRelease2, model.Random(T1 - T1_dop, T1 + T1_dop), transact); } else { // Stage gives info is it item from first input or second inputQueue.Add(transact, 2); } break; } case Events.ProcessorRelease1: { processor.Release(); if (inputQueue.Count > 0) { UInt64 transactId = inputQueue.Dequeue(out UInt64 stage).TransactId; // In case if transact from first input is placed on top of queue generate ProcessorReserve1 otherwise ProcessorReserve2 if (stage == 1) { model.Schedule((int)Events.ProcessorReserve1, 0, transactId); } else if (stage == 2) { model.Schedule((int)Events.ProcessorReserve2, 0, transactId); } } model.Schedule((int)Events.OutputBufferReserve1, 0, transact); break; } case Events.ProcessorRelease2: { processor.Release(); if (inputQueue.Count > 0) { UInt64 transactId = inputQueue.Dequeue(out UInt64 stage).TransactId; // In case if transact from first input is placed on top of queue generate ProcessorReserve1 otherwise ProcessorReserve2 if (stage == 1) { model.Schedule((int)Events.ProcessorReserve1, 0, transactId); } else if (stage == 2) { model.Schedule((int)Events.ProcessorReserve2, 0, transactId); } } model.Schedule((int)Events.OutputBufferReserve2, 0, transact); break; } case Events.OutputBufferReserve1: { if (outputBuffer1.GetState() == Device.State.Idle) { outputBuffer1.Reserve(transact); model.Schedule((int)Events.OutputBufferRelease1, model.Random(T2 - T2_dop, T2 + T2_dop), transact); } else { outputQueue1.Add(transact, 0); } break; } case Events.OutputBufferReserve2: { if (outputBuffer2.GetState() == Device.State.Idle) { outputBuffer2.Reserve(transact); model.Schedule((int)Events.OutputBufferRelease2, model.Random(T3 - T3_dop, T3 + T3_dop), transact); } else { outputQueue2.Add(transact, 0); } break; } case Events.OutputBufferRelease1: { outputBuffer1.Release(); if (outputQueue1.Count > 0) { UInt64 transactId = outputQueue1.Dequeue(out UInt64 stage).TransactId; if (stage == 0) { model.Schedule((int)Events.OutputBufferReserve1, 0, transactId); } } m_currentItems1--; resultQueue1.Add(transact, 1); break; } case Events.OutputBufferRelease2: { outputBuffer2.Release(); if (outputQueue2.Count > 0) { UInt64 transactId = outputQueue2.Dequeue(out UInt64 stage).TransactId; if (stage == 0) { model.Schedule((int)Events.OutputBufferReserve2, 0, transactId); } } m_currentItems2--; resultQueue2.Add(transact, 1); break; } case Events.End: { break; } default: { throw new Exception(); } } }while (@event != Events.End); using (HtmlReporter htmlReporter = new HtmlReporter(model)) { htmlReporter.GetReport("output.html"); } }
public void CompareScreenshot(string filename, By byObject = null) { bool DAILY_REPORT_ENABLED = Convert.ToBoolean(ConfigurationManager.AppSettings["DAILY_REPORT_ENABLED"]); bool UI_TEST_ENABLED = Convert.ToBoolean(ConfigurationManager.AppSettings["UI_TEST_ENABLED"]); int threshold = Convert.ToInt32(ConfigurationManager.AppSettings["IMAGE_COMPARE_THRESHOLD"]); string strScreenshotFileName = filename + ".png"; string strBaseLineImage = Utils.BaselinePath + Utils.separator + strScreenshotFileName; string strActualImage = Utils.ActualScreenshotPath + Utils.separator + strScreenshotFileName; string strDiffImage = Utils.DiffScreenshotPath + Utils.separator + strScreenshotFileName; try { if (!(DAILY_REPORT_ENABLED && UI_TEST_ENABLED)) { throw new Exception("Enable both option DAILY_REPORT_ENABLED and UI_TEST_ENABLED to active the UI testing mode"); } WaitForFullPageLoaded(); if (!File.Exists(strBaseLineImage)) { if (byObject == null) { CaptureScreenshot(Utils.BaselinePath, filename); } else { CaptureScreenshot(Utils.BaselinePath, filename, byObject); } NLogger.Info("The baseline screenshot of [" + filename + "] not exist, creating it"); HtmlReporter.Pass("The baseline screenshot of [" + filename + "] not exist, creating it"); } else { if (byObject == null) { CaptureScreenshot(Utils.ActualScreenshotPath, filename); } else { CaptureScreenshot(Utils.ActualScreenshotPath, filename, byObject); } Bitmap diffImage = ImageCompare.DiffImage(strActualImage, strBaseLineImage, threshold); if (diffImage == null) { NLogger.Info("The actual screenshot of [" + filename + "] matches with the baseline"); HtmlReporter.Pass("The actual screenshot of [" + filename + "] matches with the baseline", strActualImage); } else { diffImage.Save(strDiffImage); //NLogger.Error("The actual screenshot of [" + filename + "] not matches with the baseline"); HtmlReporter.Fail("The actual screenshot of [" + filename + "] not matches with the baseline", strDiffImage); throw new Exception("The actual screenshot of [" + filename + "] not matches with the baseline"); } } } catch (Exception ex) { string message = string.Format("There is an error when comparing the screenshot of page [{0}]", filename); //HtmlReporter.Fail(message, ex); throw new ErrorHandler(message, ex); } }
public void BeforeEachStep() { var step = ScenarioStepContext.Current.StepInfo.StepInstance; HtmlReporter.CreateNode(step.Keyword, step.Text); }
public YahooTestOperations() { htmlReporter = HtmlReporter.GetInstance(); }
public void TwoVulnerabilities() { var reporter = new HtmlReporter(_consoleWrapper.Object); reporter.Start(); reporter.Report(new Vulnerability { Code = "ExampleCode", Title = "Example Vulnerability", SeverityLevel = SeverityLevel.Critical, Description = "Description here.", FilePath = "C:\\Program.cs", FullyQualifiedName = "Namespace.Class", LineNumber = 10 }); reporter.Report(new Vulnerability { Code = "ExampleCode2", Title = "Example Vulnerability", SeverityLevel = SeverityLevel.Critical, Description = "Description here.", FilePath = "C:\\Program.cs", FullyQualifiedName = "Namespace.Class", LineNumber = 20 }); reporter.Finish(); Assert.AreEqual(@"<!DOCTYPE html> <html lang=""en""> <head> <title>Xamarin Security Scanner</title> <meta charset=""utf-8""> <meta name=""viewport"" content=""width=device-width, initial-scale=1""> </head> <body> <table> <tr> <th>Code</th> <th>Title</th> <th>SeverityLevel</th> <th>Description</th> <th>FilePath</th> <th>FullyQualifiedName</th> <th>LineNumber</th> </tr> <tr> <td>ExampleCode</td> <td>Example Vulnerability</td> <td>Critical</td> <td>Description here.</td> <td>C:\Program.cs</td> <td>Namespace.Class</td> <td>10</td> </tr> <tr> <td>ExampleCode2</td> <td>Example Vulnerability</td> <td>Critical</td> <td>Description here.</td> <td>C:\Program.cs</td> <td>Namespace.Class</td> <td>20</td> </tr> </table> </body> </html> ".NormalizeEndOfLine(), _output.ToString()); }
public void WhenIEatCucumbers(int eat) { HtmlReporter.Pass("I eat " + eat); this.eat = eat; }
public void GivenThereAreCucumbers(int start) { HtmlReporter.Pass("I have " + start); this.start = start; }