SpecFlowOSS / SpecFlow.Rider

SpecFlow support for both ReSharper and Rider
MIT License
29 stars 18 forks source link

Rider cannot find a matching step definition for a Scenario Outline step #194

Closed aventus13 closed 1 year ago

aventus13 commented 1 year ago

Problem description

Hello, I'm having the following problem in Rider. Consider the below step:

# Removed for brevity
# ....
And the request contains invalid parameter <ParameterName> set to <Value>
# ....
Examples: 
    | ParameterName    | Value |
    | givenName           |           |

The tests pass correctly, however, the IDE throws the following warning: image "Cannot find a matching step definition"

Interestingly, I tried following the recommendation from Specflow documentation and wrapped the arguments with apostrophes. This stops the IDE from complaining about the missing step definition. However, tests start treating the argument names as actual values, and thus my tests fail.

image

I deleted the generated step definition files each time after making an update, thus ensuring that step definitions get regenerated. It's worth noting that the problem only exists in some places. I opened one of the older repos, and the IDE doesn't display the warning.

System specification

JetBrains Rider 2022.3.2 Runtime version: 17.0.5+1-b653.25 amd64 .NET 7

Socolin commented 1 year ago

What regex do you use in the pattern ? The current code try to find it by applying the regex to the string with the <> so if you use .+ it should work

[Given("the first number is (.*)")]

will match

Given the first number is <Number1>

Ideally the plugin should replace those with the first value available and try to match this way

aventus13 commented 1 year ago

Hi @Socolin, this is exactly the pattern that I'm using:

[Given("the first number is (.*)")]

I checked other scenarios, played about with it and I think that I came to the bottom of what's causing the issue.

There are cases with multiple steps, each steps referencing a different named value, and some of them work while others don't. All steps use the same pattern, and all have the value referenced at the end of the sentence. The only one that doesn't work has its first value empty- it's the only difference. When I change the first value, e.g. to test, Specflow detects the step definition and can navigate to it.

unnamed

unnamed

unnamed

Socolin commented 1 year ago

I found the problem, there was a .Trim() that was removing the last space when, in this case, it should not