Great Visual Studio integration - another of the many reasons to upgrade to SpecFlow 1.9

· August 9, 2012

This is a small tribute to a great tool. Mostly for fun but there are some great stuff in the latest release of SpecFlow. Check it out. And get the tool from the Visual Studio Gallery, but be sure to uninstall any previous versions first.

For more serious look on 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 that not only Vs2010 solutions opens nicely in Vs2012 but also the new release of SpecFlow works fine for both.

Where was he now again. There were something about the feature file. He opens it and due to the nice color coding of lines, Marcus is reminded of one of the steps that he didn’t had written a step definition for.

Screen Shot 2012-08-09 at 21.09.06

“Then the result should be 120”…

“This should not be too hard” - he thinks and hit F12 on the step in the .feature file. As always the helpful little dialog opens giving him the implementation. And look – it’s now parsing out a regular expression at the right place.

Screen Shot 2012-08-09 at 20.39.22

He simply paste the implementation into the class file and fills out the implementation, with a couple of simple lines.

“Hmmm was that all then?”, Marcus thinks for 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.

“Ok – get a grip, Marcus. That just too geeky” he says out loudly and right-clicks the feature file and chose 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 the ones we have. I’ll just implement these at they stand”. Marcus right-clicks the scenario and choses Generate Step Definitions. This open this dialog box:

Screen Shot 2012-08-09 at 20.53.30

Marcus picks to go with 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 choses to copy the methods to the clipboard and simply paste 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 seen that before.”

Screen Shot 2012-08-09 at 21.07.17

“I’m sure happy that I have such a great tool to help me out. Makes my work both easy and fun.”

Marcus heads over the SpecFlow website and is greeted with a new site. And a new logo!!!

He almost, but only almost, misses the pixels, rough edges and 80-ies look of the old logo.

Twitter, Facebook