SpecFlowOSS / SpecFlow.VisualStudio

Visual Studio extension of SpecFlow (extracted from the main SpecFlow repo)
Other
67 stars 73 forks source link

SpecFlow bad parsing of feature file #181

Open StefanZivkovic opened 4 years ago

StefanZivkovic commented 4 years ago

SpecFlow Version:

Used Test Runner

Version number: 2.6.2.12296

Project Format of the SpecFlow project

.feature.cs files are generated using

Visual Studio Version

Enable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings

Are the latest Visual Studio updates installed?

.NET Framework:

Test Execution Method:

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

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
  </configSections>
  <specFlow>
    <!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config -->
  </specFlow>
</configuration>

Repro Project

https://github.com/StefanZivkovic/SpecFlow

Issue Description

After implementing 3 step bindings with advanced regex, some steps in feature file start to be unrecognized (which beginnings And, When or Then are not recognized as keywords, but simple black text). Regex:

[Given(@"Slave side is configured( with ""([0-9, ]*)"" byte block analyzer)?")]
[Then(@"Channel\s*(with "".+"")? is ""(Connected|Disconnected|Connecting|NoReply)""")]
[When(@"Channel( with "".+"")? is ""(Connected|Disconnected|Connecting|NoReply)""")]

We have different steps in feature files and we try to utilize one step binding so regex for that step binding ends with a bit advance pattern. We have capturing groups inside, but what i noticed that makes this problem is optional space before capturing group. I tried to match optional space with different patterns - \s*, \s{0,1}, {0,1}, i also tried to put space inside capturing group with removing space matching pattern before capturing group. Also, there are errors showing in output window when tracer for specflow is enabled. But tricky thing is that when i comment any of step bindings there are 4 or less errors and parser seems to behave nice when, at least that is what i noticed. When there are 6 errors (3 step bindings), then this problem occurs.

ProjectFeatureFilesTracker: Cannot detect generated test version for file: SpecFlowFeature1.feature, error: Version string portion was too short or too long.

Same thing happens in Visual Studio 2019 and SpecFlow for Visual Studio 2019

Steps to Reproduce

Details in Issue Description

EmilyRocks commented 3 years ago

Hi! I am running into this issue too. Is there a workaround for this? Since it began I cannot run any tests.