Lets say i have a scenario in feature file like below
Given I log in as "super" user
When I click on login
Then Home page is displayed
With corresponding step definitions:
[Given(@"I log in as ""(.*)"" user")]
public void GivenIHaveLogInAsUser(string p0)
{
ScenarioContext.Current.Pending();
}
Now I want to change
Given I log in as "super" user
To
Given I have logged in as "super" user
When I make this change in feature file how to get SpecFlow to make this change automatically in the step definition.
UPDATE
This feature was added in a fairly recent update, so you should be able to follow the instructions here, which basically say
You can globally rename steps and update the associated bindings automatically. To do so:
- Open the feature file containing the step.
- Right-click on the step you want to rename and select Rename from the context menu.
- Enter the new text for the step in the dialog and confirm with OK.
- Your bindings and all feature files containing the step are updated.
Note: If the rename function is not affecting your feature files, you may need to restart Visual Studio to flush the cache.
previous answer
This is not possible I don't believe. you have 2 options:
like so:
[Given(@"I log in as ""(.*)"" user")]
[Given(@"I have logged in as ""(.*)"" user")]
public void GivenIHaveLogInAsUser(string p0)
{
ScenarioContext.Current.Pending();
}
This will allow steps with both pieces of text to match
Bit late to this thread, but you may use visual studios find and replace tool with regex enabled to replace both the step definition and the step implementations together.
e.g for the step definition: Given I have a message '(.*)' that is (.*) characters long
, we can use the step definition itself to use in search for any matching steps, and replace with the new step. $n can be used to carry over regex matches picked up in the find.
Find: I have a message '(.*)' that is (.*) characters long
Replace: I have a message $1 that is $2 characters in length
Result: 'I have a message 'myMessage' that is 100 characters long'
becomes 'I have a message 'myMessage' that is 100 characters in length'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With