public void OnAfterLastStep() { HandleBlockSwitch(ScenarioBlock.None); if (runtimeConfiguration.TraceTimings) { contextManager.ScenarioContext.Stopwatch.Stop(); var duration = contextManager.ScenarioContext.Stopwatch.Elapsed; testTracer.TraceDuration(duration, "Scenario: " + contextManager.ScenarioContext.ScenarioInfo.Title); } if (contextManager.ScenarioContext.TestStatus == TestStatus.OK) { return; } if (contextManager.ScenarioContext.TestStatus == TestStatus.StepDefinitionPending) { var pendingSteps = contextManager.ScenarioContext.PendingSteps.Distinct().OrderBy(s => s); errorProvider.ThrowPendingError(contextManager.ScenarioContext.TestStatus, string.Format("{0}{2} {1}", errorProvider.GetPendingStepDefinitionError().Message, string.Join(Environment.NewLine + " ", pendingSteps.ToArray()), Environment.NewLine)); return; } if (contextManager.ScenarioContext.TestStatus == TestStatus.MissingStepDefinition) { var missingSteps = contextManager.ScenarioContext.MissingSteps.Distinct().OrderBy(s => s); string bindingSkeleton = currentStepDefinitionSkeletonProvider.GetBindingClassSkeleton( string.Join(Environment.NewLine, missingSteps.ToArray())); errorProvider.ThrowPendingError(contextManager.ScenarioContext.TestStatus, string.Format("{0}{2}{1}", errorProvider.GetMissingStepDefinitionError().Message, bindingSkeleton, Environment.NewLine)); return; } if (contextManager.ScenarioContext.TestError == null) { throw new InvalidOperationException("test failed with an unknown error"); } contextManager.ScenarioContext.TestError.PreserveStackTrace(); throw contextManager.ScenarioContext.TestError; }
public void OnAfterLastStep() { HandleBlockSwitch(ScenarioBlock.None); if (_specFlowConfiguration.TraceTimings) { _contextManager.ScenarioContext.Stopwatch.Stop(); var duration = _contextManager.ScenarioContext.Stopwatch.Elapsed; _testTracer.TraceDuration(duration, "Scenario: " + _contextManager.ScenarioContext.ScenarioInfo.Title); } if (_contextManager.ScenarioContext.ScenarioExecutionStatus == ScenarioExecutionStatus.OK) { return; } if (_contextManager.ScenarioContext.ScenarioExecutionStatus == ScenarioExecutionStatus.StepDefinitionPending) { var pendingSteps = _contextManager.ScenarioContext.PendingSteps.Distinct().OrderBy(s => s); _errorProvider.ThrowPendingError(_contextManager.ScenarioContext.ScenarioExecutionStatus, string.Format("{0}{2} {1}", _errorProvider.GetPendingStepDefinitionError().Message, string.Join(Environment.NewLine + " ", pendingSteps.ToArray()), Environment.NewLine)); return; } if (_contextManager.ScenarioContext.ScenarioExecutionStatus == ScenarioExecutionStatus.UndefinedStep) { string skeleton = _stepDefinitionSkeletonProvider.GetBindingClassSkeleton( _defaultTargetLanguage, _contextManager.ScenarioContext.MissingSteps.ToArray(), "MyNamespace", "StepDefinitions", _specFlowConfiguration.StepDefinitionSkeletonStyle, _defaultBindingCulture); _errorProvider.ThrowPendingError(_contextManager.ScenarioContext.ScenarioExecutionStatus, string.Format("{0}{2}{1}", _errorProvider.GetMissingStepDefinitionError().Message, skeleton, Environment.NewLine)); return; } if (_contextManager.ScenarioContext.TestError == null) { throw new InvalidOperationException("test failed with an unknown error"); } _contextManager.ScenarioContext.TestError.PreserveStackTrace(); throw _contextManager.ScenarioContext.TestError; }
public void Handle(BindingMatch bindingMatch) { if (bindingMatch.IsObsolete) { switch (specFlowConfiguration.ObsoleteBehavior) { case ObsoleteBehavior.None: break; case ObsoleteBehavior.Warn: testTracer.TraceWarning(bindingMatch.BindingObsoletion.Message); break; case ObsoleteBehavior.Pending: throw errorProvider.GetPendingStepDefinitionError(); case ObsoleteBehavior.Error: throw errorProvider.GetObsoleteStepError(bindingMatch.BindingObsoletion); } } }
public virtual void Pending() { throw _errorProvider.GetPendingStepDefinitionError(); }
public string BuildFromScenarioContext(ScenarioContext scenarioContext) { var pendingSteps = scenarioContext.PendingSteps.Distinct().OrderBy(s => s); return($"{_errorProvider.GetPendingStepDefinitionError().Message}{Environment.NewLine} {string.Join(Environment.NewLine + " ", pendingSteps)}"); }