/// <summary> /// Reports steps and tests to the Agent. /// </summary> /// <param name="sender">The event sender.</param> /// <param name="eventArgs">Arguments passed to the event.</param> private void RuntimePluginTestExecutionLifecycleEvents_AfterStep(object sender, RuntimePluginAfterStepEventArgs eventArgs) { if (AgentClient.IsInitialized()) { ScenarioContext context = eventArgs.ObjectContainer.Resolve <ScenarioContext>(); string scenarioTitle; if (context.ScenarioInfo.Arguments.Count > 0) { // If a scenario has arguments, it means it is an example from a Scenario Outline // Similar to what SpecFlow itself does, we append the value from the first argument // to the name of the current scenario to uniquely identify it scenarioTitle = $"{context.ScenarioInfo.Title} [{context.ScenarioInfo.Arguments[0]}]"; } else { // If a scenario does not have arguments, we consider it to be a 'regular' scenario // In this case, we use the Scenario title as the name of the test scenarioTitle = context.ScenarioInfo.Title; } // Create a preliminary test report in the AgentClient (will not be reported until AgentClient is stopped). AgentClient.GetInstance().SpecFlowTestReport = new TestReport(scenarioTitle, true, context.ScenarioInfo.Description); string stepText = $"{context.StepContext.StepInfo.StepDefinitionType} {context.StepContext.StepInfo.Text}"; StepReport stepReport; if (context.TestError == null) { stepReport = new StepReport(stepText, context.StepContext.StepInfo.MultilineText, true, null); } else { stepReport = new StepReport(stepText, context.TestError.Message, false, null); } AgentClient.GetInstance().ReportStep(stepReport); } else { string message = $"No active Agent development session found. Please ensure that you have an instance of a TestProject OpenSDK driver running.\n" + $"More information on how to do that can be found in the README at https://github.com/testproject-io/csharp-opensdk"; Logger.Error(message); throw new NoActiveDriverFoundException(message); } }
private void RuntimePluginTestExecutionLifecycleEvents_AfterStep(object sender, RuntimePluginAfterStepEventArgs e) { var scenarioContext = e.ObjectContainer.Resolve <ScenarioContext>(); if (scenarioContext.ScenarioExecutionStatus != ScenarioExecutionStatus.OK) { //we have an error in the step } }