2
votes

Is there a way i can "regenerate" steps for the scenarios in specflow.

Currently my feature file has steps which are already bound to it. I would like to generate steps again and write the code all over again without deleting my previous step files.

In case you are wondering why i am doing this, it's related to maintaining the test case. the steps written initially have too much duplication.

REgards

2

2 Answers

1
votes

The easiest way I can think of to do this would be to exclude the current steps files from your project (right click on the file in the solution explorer-> Exclude from project) and then you'll be able to regenerate them from the scenario file again.

3
votes

While I realise that you've posted this because of SpecFlow, I'm wondering if your problem is really that different to a normal code refactoring problem. Do you really want to throw everything out and start again, or do you just need some help in order to improve the codebase?

Personally (having done the wrong thing before) I would now keep what you have and simply start to refactor it so it's cleaner. I tend to use TeamCity to have a nightly build that checks the codebase and detects code duplicates. That way I can come in every morning first thing and kill off the worst one. If you would rather do it more interactively, then you can either use VSs Analyze->Analyze solution for Code Clones, or some other means of finding them, and then use tidy them up.

The advantage to doing this as you go along rather than cleaning up and starting again, is that you don't stop your development. If you throw everything away, you might be days or weeks before you can run your test suite again. If you do it a bit at a time, you can get interrupted to do something critical and you only have to finish your current refactor before you can run your tests.