SpecFlow icon indicating copy to clipboard operation
SpecFlow copied to clipboard

SpecFlow for VS2022 plugin: poor regex recognition

Open mumaguma opened this issue 1 year ago • 4 comments
trafficstars

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 avatar Feb 26 '24 23:02 mumaguma

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

mumaguma avatar Feb 27 '24 10:02 mumaguma

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

mumaguma avatar Feb 27 '24 12:02 mumaguma

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

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

clrudolphi avatar Apr 01 '24 16:04 clrudolphi

unfortunately not with current customer

mumaguma avatar May 08 '24 17:05 mumaguma