public static void BeforeTestRun() { string dataHora = ClassUtilities.PegarDataHora(); //var htmlReporter = new ExtentHtmlReporter(@"C:\Users\leonardo.barcellos\Desktop\Fundacred\AutomacaoFuncional\Reports\" + dataHora + " Report.html"); //htmlReporter.Configuration().DocumentTitle = "Leonardo - Teste Extent Report"; //htmlReporter.Configuration().Theme = Theme.Dark; //extent.AttachReporter(htmlReporter); //extent.AddSystemInfo("Automação", "Leonardo Barcellos"); //extent.AddSystemInfo("SO", "win10"); //extent = new ExtentReports(); //////Klov reporter //KlovReporter klov = new KlovReporter(); ////// specify mongoDb connection ////klov.InitMongoDbConnection("app.fundacred.org.br", 27017); ////// specify project ! you must specify a project, other a "Default project will be used" //klov.ProjectName = "Fundacred - Testes Automatizados"; ////// you must specify a reportName otherwise a default timestamp will be used //klov.ReportName = "Build " + DateTime.Now.ToString(); ////// URL of the KLOV server //klov.KlovUrl = "http://app.fundacred.org.br:9090"; ////// finally, attach the reporter: //extent.AttachReporter(klov); }
public static void AfterStep() { string errorImage = ClassUtilities.PegarDataHora(); var stepType = ScenarioStepContext.Current.StepInfo.StepDefinitionType.ToString(); if (ScenarioContext.Current.ScenarioExecutionStatus.ToString() == "StepDefinitionPending") { if (stepType == "Given") { scenario.CreateNode <Given>(ScenarioStepContext.Current.StepInfo.Text).Skip("Step pendente"); } else if (stepType == "When") { scenario.CreateNode <When>(ScenarioStepContext.Current.StepInfo.Text).Skip("Step pendente"); } else if (stepType == "Then") { scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text).Skip("Step pendente"); } } else { if (ScenarioContext.Current.TestError == null) { if (stepType == "Given") { scenario.CreateNode <Given>(ScenarioStepContext.Current.StepInfo.Text); } else if (stepType == "When") { scenario.CreateNode <When>(ScenarioStepContext.Current.StepInfo.Text); } else if (stepType == "Then") { scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text); } else if (stepType == "And") { scenario.CreateNode <And>(ScenarioStepContext.Current.StepInfo.Text); } } else if (ScenarioContext.Current.TestError != null) { if (stepType == "Given") { scenario.CreateNode <Given>(ScenarioStepContext.Current.StepInfo.Text).Fail(ScenarioContext.Current.TestError.Message) .Fail("<br/>Screenshot <br/><br/>", MediaEntityBuilder.CreateScreenCaptureFromPath(GetScreenShot.Capture(ClassDriver.GetInstance().Driver, errorImage)).Build()); } else if (stepType == "When") { scenario.CreateNode <When>(ScenarioStepContext.Current.StepInfo.Text).Fail(ScenarioContext.Current.TestError.Message) .Fail("<br/>Screenshot <br/><br/>", MediaEntityBuilder.CreateScreenCaptureFromPath(GetScreenShot.Capture(ClassDriver.GetInstance().Driver, errorImage)).Build()); } else if (stepType == "Then") { scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text).Fail(ScenarioContext.Current.TestError.Message) .Fail("<br/>Screenshot <br/><br/>", MediaEntityBuilder.CreateScreenCaptureFromPath(GetScreenShot.Capture(ClassDriver.GetInstance().Driver, errorImage)).Build()); } } } }