SpecFlow Auto generated StepDefinition File, is it possible?
I'm currently programming in C# and I am using Visual Studio 2010, .Net 4, SpecFlow, NUnit and I'm curious if there is a way for SpecFlow to automatically generate me a *StepDefintion.cs for my *.feature file. Currently I have to copy and paste the generated code into a new 开发者_StackOverflow中文版"SpecFlow Step Definition" File.
If anyone knows if this is possible, and how to do it that would be great!
The latest version of SpecFlow has this feature within the IDE integration..
Select “Generate Step Definitions” from the context menu of the feature file and the appearing dialog will guide you how to create a new binding class with the step definitions for the selected unbound steps. You don’t have to care about parameters: the most common parameter usage patterns (quotes, apostrophes, numbers) are detected. You can also choose from different step definition styles, including the new regex-less formats (see below).
http://www.specflow.org/specflownew/WhatsNew19.html
Not out of the box. There is a tutorial on using nUnit and geting the code to rough in the steps, but I did not use SpecFlow for our project long enough to determine where it generates this stub code. A bit of searching should find the answer. Worst case, find the tutorial for SpecFlow and nUnit with the code generated in nUnit (pretty neat stuff, although not automated).
I have some code somewhere that I started to write to create the stub file, but the decision not to use SpecFlow moved me away from this direction (could not justify the time any more). I thought I blogged it but a search of my blog yielded nada (ASIDE: you can find SpecFlow at site:gregorybeamer.wordpress.com, but it is a general "unit testing" post).
I had thought about contribing the code, but the number of different possibilities made my head swim considering the lack of free time I have now to contrib to open source. ;-)
精彩评论