Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpecFlow for VS2022 plugin: poor regex recognition #2740

Open
mumaguma opened this issue Feb 26, 2024 · 4 comments
Open

SpecFlow for VS2022 plugin: poor regex recognition #2740

mumaguma opened this issue Feb 26, 2024 · 4 comments
Labels

Comments

@mumaguma
Copy link

mumaguma commented Feb 26, 2024

SpecFlow Version

3.9.74

Which test runner are you using?

NUnit

Test Runner Version Number

3.13.3

.NET Implementation

.NET 6.0

Project Format of the SpecFlow project

Sdk-style project format

.feature.cs files are generated using

SpecFlow.Tools.MsBuild.Generation NuGet package

Test Execution Method

Visual Studio Test Explorer

SpecFlow Section in app.config or content of specflow.json

  1. it is not specflow that causes trouble, but SpecFlow for Visual Studio 2022 extension. App.config or specflow.json is not relevant here

Issue Description

  1. .NET implementation is 8.0, but this bug form does not allow anything newer than 6.0.

For step definition such as:
[When(@"I click the (.*) element( and wait)?"]
public async Task IClickElement(string elementName, string optionalWait="")
`

Specflow 3.9.74 recognizes it correctly during execution, regardless if " and wait" is present in the step or not. Both in VS TestExplorer, as well as with command line.
Command line: dotnet test --environment /here some settings to indicate testing environment, not relevant here/

But "SpecFlow for Visual Studio 2022" v2022.1.93 - 2023-11-28 fails to recognize this regex in step definition.
Underlined steps in VS have error:
"The method BaseSteps.IClickElement(String, String) has invalid parameter count, 1 parameter(s) expected"

This time I can resort to changing step def to
[When(@"I click the (.*) element(| and wait)"]
but in the past (and java) there had been steps I could not go for such workaround. Better regex implementation to the plugin would be nice, especially that the specflow library itselt / dotnet dit not have issues during execution of this step.

Steps to Reproduce

  1. Have VS2022, plugin SpecFlow for Visual Studio 2022 in v2022.1.93, nunit 3.13.3
  2. define step binding with regex with optional parameter such as:
    [When(@"I click the (.*) element( and wait)?"]
    public async Task IClickElement(string elementName, string optionalWait="")
    `
  3. IDE highlights step "When I click abc element" but accepts "When I click abc element and wait"
    with
    "The method BaseSteps.IClickElement(String, String) has invalid parameter count, 1 parameter(s) expected" message
    (but runtime works).

Link to Repro Project

No response

@mumaguma mumaguma added the Bug label Feb 26, 2024
@mumaguma
Copy link
Author

'(?: and wait)?' also doesn't work

@mumaguma
Copy link
Author

by regex101.com '(?: and wait)?' is ok
obraz

I've discovered, that when I use '(?:| and wait)?' in scenario, than plugin recognises step. But by regex101.com this is not correct.
obraz

@clrudolphi
Copy link
Contributor

'(?: and wait)?' also doesn't work

'(?: and wait)? does work in Reqnroll , can you migrate to Reqnroll?

@mumaguma
Copy link
Author

mumaguma commented May 8, 2024

unfortunately not with current customer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants