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

Step definition not reconized in feature files #2723

Open
DomZZ opened this issue Oct 18, 2023 · 1 comment
Open

Step definition not reconized in feature files #2723

DomZZ opened this issue Oct 18, 2023 · 1 comment
Labels

Comments

@DomZZ
Copy link

DomZZ commented Oct 18, 2023

SpecFlow Version

4.0.31-beta

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

{
"$schema": "https://specflow.org/specflow-config.json",
"generator": {
"addNonParallelizableMarkerForTags": [ "nonparallelizable" ]
},
"runtime": {
"missingOrPendingStepsOutcome": "Error"
}
}

Issue Description

I added a step definition with a param (regular expression that should accept 2 different strings (collapse or expand)
then in the C# method I know how to behave depending on the param value.

But the step definition that is not reconized in feature files...

Steps to Reproduce

[When(@"I click on summary card ""(expand|collapse)"" button")]
public void WhenIClickOnSummaryCardCollapseExpandButton(string cardAction)
{
   throw new PendingStepExpception();
}

But I've observed that if there is other params it works :

[When(@"I click on summary card ""(expand|collapse)"" button with label ""([^""]*)""")]
public void WhenIClickOnSummaryCardCollapseExpandButton(string cardAction, string label)
{
   throw new PendingStepExpception();
}

Link to Repro Project

No response

@DomZZ DomZZ added the Bug label Oct 18, 2023
@mharwig
Copy link

mharwig commented Oct 20, 2023

This is likely because specflow since 4.0 allows both cucumber and regular expressions. This is automatically determined, but for this this step it makes an incorrect conclusion. To work around this you can write down the step as follow:
@"^I click on summary card ""(expand|collapse)"" button$"
to ensure it is always detected as a regular expression.

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