This is a small tribute to a great tool. Mostly for fun, but there are some great features in the latest release of SpecFlow. Check it out. You can get the tool from the Visual Studio Gallery, but be sure to uninstall any previous versions first.
For a more serious look at some of the code features, head over to Vagif Abilov’s excellent post.
Marcus enters the office. He boots up the computer and opens Visual Studio 2012. With a smile, he thinks about how not only Vs2010 solutions open nicely in Vs2012, but also the new release of SpecFlow works fine for both.
Where was he now again? There was something about the feature file. He opens it and, thanks to the nice color coding of lines, Marcus is reminded of a step that he didn’t have a step definition for.
“Then the result should be 120”…
“This should not be too hard,” he thinks and hits F12 on the step in the .feature file. As always, the helpful dialog opens, providing him with the implementation. And look – it’s now parsing out a regular expression at the right place.
He simply pastes the implementation into the class file and fills it out with a couple of simple lines.
“Hmmm, was that all then?” Marcus thinks to himself. Inside the step definition method, Marcus hits Ctrl+Shift+Alt+S and is taken back to the feature file. Hitting the same command again takes him back to the step definition. He goes back and forth a couple of times, just because it’s so slick.
“Okay – get a grip, Marcus. That’s just too geeky,” he says out loud and right-clicks the feature file, choosing “Run SpecFlow Scenarios.” Immediately, the Reshaper test runner is picked up and executes the tests. Green!
“Great – now what? Yeah – that’s right… The new scenario from big boss Hugo needed to be implemented.” Marcus adds the following scenario to the feature:
Scenario: Subtracting two numbers
Given the first number is 50
And the second number is 20
When I do a subtract
Then the presented result should be 30
“That was a lot of new step definitions… and very similar to the ones we have. I’ll just implement these as they stand.” Marcus right-clicks the scenario and chooses “Generate Step Definitions.” This opens the following dialog box:
Marcus opts for Pascal-cased methods without regular expressions… “Just as I started to pick that up…” he thinks but is also happy that the option exists.
He chooses to copy the methods to the clipboard and simply pastes the method stubs into the existing class.
The implementation of the step definitions and the subsequent production code goes smoothly, and before long, the scenario is passing.
Looking back over his work, one final thing strikes him… “Look, all the variables are italics and grey, nice! Huh – haven’t seen that before.”
“I’m sure happy that I have such a great tool to help me out. It makes my work both easy and fun.”
Marcus heads over to the SpecFlow website and is greeted with a new site. And a new logo!!!