reqnroll / Reqnroll.VisualStudio

Visual Studio extension for Reqnroll - open-source .NET BDD framework
https://reqnroll.net
BSD 3-Clause "New" or "Revised" License
14 stars 5 forks source link

Problem matching steps in the editor #38

Open JimCooperFromGmailAccount opened 1 month ago

JimCooperFromGmailAccount commented 1 month ago

Used Visual Studio

Visual Studio 2022

Are the latest Visual Studio updates installed?

Yes

Content of reqnroll.json (if present)

No response

Issue Description

There is an issue in the editor, where these pairs of step definitions are marked as ambiguous. So they are marked with a red squiggly line, and also go to declaration/definition doesn't work The feature.cs files are generated and the tests pass, correctly, with the correct steps being hit.

It seems to be an issue with using enums (here BeDeletedOrNot, Pep, WikiMarkup and OnOrOff are all enums) It's like the regular expression (.*) is being used in the analysis instead of the possible enum values.

[Then("the batch with ID {int} should {BeDeletedOrNot}")] [Then("the batch with ID {int} should be updated")]

[Then("the projected value of {Pep}[{int}] should be {double}")] [Then("{WikiMarkup} should be {OnOrOff}")]

Steps to Reproduce

Create steps using enums, as shown above. The problems are all in the editor. The tests themselves are generated correctly

Link to a project repository that reproduces the issue

No response

gasparnagy commented 1 month ago

To simplify the things, for example the two step defs are marked as ambiguous (although they work fine as test):

[Then("the batch with ID {int} should {BeDeletedOrNot}")]
[Then("the batch with ID {int} should be updated")]

Questions:

It is really strange that it works differently in VS and in test execution, because VS should ask from the runtime what regex the cucumber expression is translated to, so the two should use the same regex at the end... But let's see.

JimCooperFromGmailAccount commented 1 month ago

HiThanks for getting back to me. To answer the questions :1. It doesn’t matter what is in an enum.2. I have not defined an argument transformation. It didn’t seem necessary. We have a lot of tests with choices, and using an enum seems to be the only way to do that in a Cucumber Expression. It would make things rather overcomplicated to also require an argument transformation. I’ll give it a try though. It does seem like the editor is using (.*) instead of (value1|value2) though CheersJimOn 19 Sep 2024, at 7:52 AM, Gáspár Nagy @.***> wrote: To simplify the things, for example the two step defs are marked as ambiguous (although they work fine as test): [Then("the batch with ID {int} should {BeDeletedOrNot}")] [Then("the batch with ID {int} should be updated")]

Questions:

What are the values in the BeDeletedOrNot enom (or it does not matter)? Do you have a [StepArgumentTransformation] defined for the enums?

It is really strange that it works differently in VS and in test execution, because VS should ask from the runtime what regex the cucumber expression is translated to, so the two should use the same regex at the end... But let's see.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

JimCooperFromGmailAccount commented 1 month ago

I tried step transforms enum->enum and string->enum but it didn't help :(

I've just noticed that the complaint about ambiguous steps is on only one of the steps. However, the parameter highlighting is correct on both steps, so it is obviously finding the right steps at some point.

On 19 Sep 2024, at 07:52, Gáspár Nagy @.***> wrote:

To simplify the things, for example the two step defs are marked as ambiguous (although they work fine as test):

[Then("the batch with ID {int} should {BeDeletedOrNot}")] [Then("the batch with ID {int} should be updated")]

Questions:

• What are the values in the BeDeletedOrNot enom (or it does not matter)? • Do you have a [StepArgumentTransformation] defined for the enums? It is really strange that it works differently in VS and in test execution, because VS should ask from the runtime what regex the cucumber expression is translated to, so the two should use the same regex at the end... But let's see.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

JimCooperFromGmailAccount commented 1 month ago

I've noticed something else in my small test project. Not all of the steps are marked as ambiguous, but sometimes the parameters are correctly coloured. I’ve attached a small test project with the scenarios detailing that. I tried writing step argument transforms, both enum to enum, and string to enum. Didn’t help, unfortunately ☹

On 19 Sep 2024, at 07:52, Gáspár Nagy @.***> wrote:

To simplify the things, for example the two step defs are marked as ambiguous (although they work fine as test):

[Then("the batch with ID {int} should {BeDeletedOrNot}")] [Then("the batch with ID {int} should be updated")]

Questions:

• What are the values in the BeDeletedOrNot enom (or it does not matter)? • Do you have a [StepArgumentTransformation] defined for the enums? It is really strange that it works differently in VS and in test execution, because VS should ask from the runtime what regex the cucumber expression is translated to, so the two should use the same regex at the end... But let's see.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

gasparnagy commented 1 month ago

@JimCooperFromGmailAccount Do you have a chance to figure out what makes the difference between the ones that are problematic and the ones that are not? Can you maybe also share the small test project (although I probably cannot check it before Monday).

JimCooperFromGmailAccount commented 1 month ago

I have a theory that an enum parameter as the first and/or last thing in the step expression is causing the trouble, because those seem to sometimes match as if they were (.*) regexes. If they're in the middle somewhere there is more to differentiate between the steps. The troublesome steps also share some common text. However, parameter highlighting still sometimes works. My attachment didn't seem to arrive last time. Hopefully it'll work this time StepAnalyserBug.zip

gasparnagy commented 1 month ago

Yes, the attachment is downloadable now. I will check it next week.

JimCooperFromGmailAccount commented 1 month ago

Excellent, thanks :-)

On 19 Sep 2024, at 11:18, Gáspár Nagy @.***> wrote:

Yes, the attachment is downloadable now. I will check it next week.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.