0

I'm writing my feature file SpecFlow and I'm looking to use numbers as a just a description. For example :

Given Site is displayed
When I check column1
And column2  
Then values are correct. 

However in the word column1, 1 is actually read as a parameter instead of a description and the method generated for the line is column(.*) instead of column1. And because of this, since I have another line for column2, only 1 method is generated for then "When" & "And" statement.

This is incorrect as I would need to check the elements for both column1 and column2. Is there a way for us to just use numbers as description in the feature file instead of parameters?

Greg Burghardt
  • 17,900
  • 9
  • 49
  • 92
captain jack
  • 65
  • 2
  • 9
  • Can you clarify what you mean by *"the word column1, 1 is actually read as a parameter instead of a description"*? What do you mean by "description"? Do you want `column1` to be a string parameter to your step definition? – Greg Burghardt Jun 14 '21 at 11:11

1 Answers1

1

You can either modify the step definition or surround the column name in double quotes.

Option A) Modify the step definition:

[When(@"I check ([^ ]+)$")]
public void WhenICheckColumn(string columnName)
{
    // Check the column
}

Option B) Surround column name in double quotes

Change the step itself:

When I check "column1"

Then change the step definition to:

[When(@"I check ""(.*)""")]
public void WhenICheckColumn(string columnName)
{
    // Check the column
}
Greg Burghardt
  • 17,900
  • 9
  • 49
  • 92