3
votes

I am new to SpecFlow and I've hit a strange issue.

I have an existing SpecFlow feature and step file. I want to add a new step and when I do this it shows the new step as unbound (purple). Then within Visual Studio 2015 I chose the option 'Generate Step Definitions', it selected the existing step file but then overwrote the file and I lost all the existing steps but my new one was added, how do I just append this new step without losing the existing steps?

Thank you

3

3 Answers

5
votes

There are a couple of other alternatives to the one you outlined

One is to go to the 'Generate Step Definitions' dialogue on on there you can select the steps you want to generate the definitions for then click the 'Copy methods to clipboard' button rather than 'Generate', and then paste the methods into the existing step file. IMHO this should be the default option.

The other is to run the tests and check the output, where a the definition required will be part of the failing test output. This option is more viable if you are using a continuous test runner like NCrunch.

2
votes

Sam has the correct flow. You want to generate the definitions the first time around and then after if step page is already created you will want to copy the steps. If you generate on a page that is already created, it will overwrite the existing steps page and you will lose any changes you made.

1
votes

I worked out how to do it, for those who are new like me you have to choose the option 'Go To Step Definition' and you will see a snippet code which you must then say 'Yes' to copy to clipboard and then paste the code inside your existing step file.