protected virtual BindingMatch GetStepMatch(StepInstance stepInstance) { var match = _stepDefinitionMatchService.GetBestMatch(stepInstance, FeatureContext.BindingCulture, out var ambiguityReason, out var candidatingMatches); if (match.Success) { return(match); } if (candidatingMatches.Any()) { if (ambiguityReason == StepDefinitionAmbiguityReason.AmbiguousSteps) { throw _errorProvider.GetAmbiguousMatchError(candidatingMatches, stepInstance); } if (ambiguityReason == StepDefinitionAmbiguityReason.ParameterErrors) // ambiguouity, because of param error { throw _errorProvider.GetAmbiguousBecauseParamCheckMatchError(candidatingMatches, stepInstance); } } _testTracer.TraceNoMatchingStepDefinition(stepInstance, FeatureContext.FeatureInfo.GenerationTargetLanguage, FeatureContext.BindingCulture, candidatingMatches); _contextManager.ScenarioContext.MissingSteps.Add(stepInstance); throw _errorProvider.GetMissingStepDefinitionError(); }
public string BuildFromContext(ScenarioContext scenarioContext, FeatureContext featureContext) { string skeleton = _stepDefinitionSkeletonProvider.GetBindingClassSkeleton( featureContext.FeatureInfo.GenerationTargetLanguage, scenarioContext.MissingSteps.ToArray(), "MyNamespace", "StepDefinitions", _specFlowConfiguration.StepDefinitionSkeletonStyle, featureContext.BindingCulture ?? CultureInfo.CurrentCulture); return($"{_errorProvider.GetMissingStepDefinitionError().Message}{Environment.NewLine}{skeleton}"); }
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; }