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(); }
private BindingMatch GetStepMatch(StepArgs stepArgs) { List <BindingMatch> matches = stepDefinitionMatcher.GetMatches(stepArgs); if (matches.Count == 0) { // there were either no regex match or it was filtered out by the param/scope matching // to provide better error message for the param matching error, we re-run // the matching without param check List <BindingMatch> matchesWithoutScopeCheck = stepDefinitionMatcher.GetMatchesWithoutScopeCheck(stepArgs); if (matchesWithoutScopeCheck.Count == 0) { List <BindingMatch> matchesWithoutParamCheck = stepDefinitionMatcher.GetMatchesWithoutParamCheck(stepArgs); if (matchesWithoutParamCheck.Count == 1) { // no ambiguouity, but param error -> execute will find it out return(matchesWithoutParamCheck[0]); } if (matchesWithoutParamCheck.Count > 1) { // ambiguouity, because of param error throw errorProvider.GetAmbiguousBecauseParamCheckMatchError(matchesWithoutParamCheck, stepArgs); } } testTracer.TraceNoMatchingStepDefinition(stepArgs, contextManager.FeatureContext.FeatureInfo.GenerationTargetLanguage, matchesWithoutScopeCheck); contextManager.ScenarioContext.MissingSteps.Add( currentStepDefinitionSkeletonProvider.GetStepDefinitionSkeleton(stepArgs)); throw errorProvider.GetMissingStepDefinitionError(); } if (matches.Count > 1) { if (runtimeConfiguration.DetectAmbiguousMatches) { throw errorProvider.GetAmbiguousMatchError(matches, stepArgs); } } return(matches[0]); }