Introducing the NBehave text based scenario VS2010 runner

 

I’ve been using NBehave for a long time now on various projects, usually using it’s fluent syntax. I wanted to move to using text based scenarios but unfortunately unless you like dropping to the command line to run your tests you were out of luck.

Now there is the wonderful looking SpecFlow, and I would be doing a disservice to the community if I didn’t mention it. It’s a very complete and increasingly popular framework for running gherkin compatible text based scenarios. However it accomplishes its task in a very different way to NBehave, and the differences are worth looking at in a separate post.

Initially John and myself took a look at making a ReSharper plug-in, however its API was driven towards running code not text and getting things working was not immediately obvious. So instead we decided on testing out the visual studio API which we had far more success with.

So let’s take a look at the new VS2010 runner and how it can make life a little easier. We will need to get the installer from the build server as the plug-in is quite new and has not made an official release yet. I would recommend getting the latest executable artefact from the following link:

http://teamcity.codebetter.com/project.html?projectId=project30

image

Now we can run the installer and ensure the plug-in is ticked, this will deploy the VSIX package into the appropriate location.

image

Assuming you have a project already using text based scenarios, or have follow Johns blog post then we should be ready to go. I already have a solution ready so let’s take a look:

image

We can see the plug-in is loaded and ready to go, I already have a feature file and it’s associated step file set up:

image

If we right click on the feature file then we will find some new context menu options:

image

Picking Run Scenario will run the scenarios in a separate process and published the results in the output window:

image

The debug option does as you would expect, and both options currently run all the scenarios in the selected file. This is the first version and is quite light on features, however there are some planned:

  1. Run a single scenario.
  2. Run from solution explorer.
  3. Syntax highlighting and completion for gherkin files.
  4. Full featured results window instead of output window.
  5. Go to step definition from scenario.
  6. Keyboard shortcuts.

I hope you find it useful, if you have any suggestions or bugs you can get me on twitter at @naeemkhedarun or on CodePlex at http://nbehave.codeplex.com

Happy coding!

blog comments powered by Disqus