Skip to content

Commit

Permalink
Update NGherkinTestExecutor
Browse files Browse the repository at this point in the history
  • Loading branch information
Romfos committed Dec 16, 2023
1 parent ad149dc commit 3bdec14
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/NGherkin.TestAdapter/NGherkinTestExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ private void RunTest(TestCase testCase, IFrameworkHandle frameworkHandle)

foreach (var step in testCaseExecutionContext.Scenario.Steps)
{
var potentialGherkinStepRegistrations = gherkinStepRegistrations.Where(x => x.Keyword == step.Keyword.Trim() && x.Pattern.IsMatch(step.Text)).ToList();
var matchedGherkinStepRegistrations = gherkinStepRegistrations
.Where(x => x.Keyword == step.Keyword.Trim() && x.Pattern.IsMatch(step.Text))
.ToList();

if (potentialGherkinStepRegistrations.Count == 0)
if (matchedGherkinStepRegistrations.Count == 0)
{
testResult.Outcome = TestOutcome.Failed;
testResult.ErrorMessage = $"Unable to find step for: {step.Keyword.Trim()} {step.Text}";
Expand All @@ -73,7 +75,7 @@ private void RunTest(TestCase testCase, IFrameworkHandle frameworkHandle)
return;
}

if (potentialGherkinStepRegistrations.Count > 1)
if (matchedGherkinStepRegistrations.Count > 1)
{
testResult.Outcome = TestOutcome.Failed;
testResult.ErrorMessage = $"Multiple steps were found for: {step.Keyword.Trim()} {step.Text}";
Expand All @@ -82,7 +84,7 @@ private void RunTest(TestCase testCase, IFrameworkHandle frameworkHandle)
return;
}

var gherkinStepRegistration = potentialGherkinStepRegistrations.Single();
var gherkinStepRegistration = matchedGherkinStepRegistrations.Single();
var targetType = scope.ServiceProvider.GetRequiredService(gherkinStepRegistration.Type);

try
Expand Down

0 comments on commit 3bdec14

Please sign in to comment.