Gáspár Nagy on software

coach, trainer and bdd addict, creator of SpecFlow; owner of Spec Solutions

SpecFlow 1.8

by Gáspár on October 26, 2011

We have released SpecFlow v1.8 recently (just published 1.8.1 with a few fixes) and I would like to take the opportunity to give a subjective summary of the new features and also some outlook for the upcoming releases.

Run & debug scenarios from context menu in VS2010

Maybe the most interesting (most wanted) feature is to make scenario execution more convenient. Now it is here: in the context menu of the editor, the project, folder or file nodes of the solution explorer, you will find new commands to run or debug the scenarios of the current context: the scenario of the cursor position (or all from the file if you stand in the header or between scenarios) or the scenarios in the files matching to the selected solution explorer node.

image

Since SpecFlow does not run the scenarios directly, but you run them with a unit test runner, this feature is a little bit tricky and needs a short explanation.

When you select the “Run SpecFlow Scenarios” command, SpecFlow tries to run the selected scenarios with your favorite unit test runner. You can either tell SpecFlow which one is your favorite or let it find out automatically based on some built-in ranking. This can be done in the SpecFlow section of the Visual Studio Tools/Options dialog.

image

From the picture you can also see the list of supported unit test runners (ReSharper (5 and 6), MsTest and SpecRun). The TDD.NET is in the list, but the gateway is not yet implemented. Contributions for the TDD.NET gateway or any other that is not listed yet is welcome.

Cucumber harmonization

As you’ve probably heard, Richard Lawrence has announced that the Cuke4Nuke project has been retired and we decided to merge our efforts to further improve SpecFlow.

We have been working for a while with Richard, Paul, Christian, Jonas and Darren for the preparation of this and we have started to implement features to be better compatible with Cucumber.

Currently we are at half-way. We have consolidated the terms (e.g. using “hook”) and validated/fixed some obvious compatibility problem. The remaining stuff is mainly concerning the table manipulation API, that is currently covered by the Assist namespace in SpecFlow. Regarding this, we would like to

  • make the table API extensions better discoverable by merging them to the main “TechTalk.SpecFlow” namespace
  • consolidate the different CompareToX methods into one
  • improve the output of the table comparison methods
Improvements in the SpecFlow architecture

SpecFlow has an evolving architecture so there are always improvements here as the features grow. 1.8 is maybe sill an interesting milestone, because we have fully refactored the class-dependency model of the runtime code and have replaced the custom object factory solution with a DI tool.

This step was important, because this consolidated and solved issues with the context injection feature (e.g. disposing injected objects) and also because this has opened up new ways for customizing SpecFlow. Here is an example for the customization:

Let’s say you want to implement a custom way of reporting SpecFlow user errors (e.g. for doing something special for pending steps). For this you need to create a class that implements the IErrorProvider interface. You can let SpecFlow use your custom provider by changing the default dependencies in the configuration like this:

image

Also the context injection feature can resolve the SpecFlow classes as well, so for example if you need to apply the same conversion logic as SpecFlow uses in your code (including step argument conversions), you can just let an IStepArgumentTypeConverter instance be injected to your step definition class like this:

image

SpecFlow tests for SpecFlow

Also a new improvement in the SpecFlow solution that now the specifications and the integration tests have got a new platform. The projects TechTalk.SpecFlow.Specs and TechTalk.SpecFlow.IntegrationTests contain SpecFlow tests for SpecFlow itself. The existing non-unit tests have been converted to the new model and I have also added a couple of additional tests, but the coverage is not yet close to complete. My hope is that with the established environment, it will be easier for the contributors to also provide SpecFlow end-to-end tests for the new features.

image

There is a similar work also in Cucumber, the cucumber-features. The goal is to make the necessary step definitions that SpecFlow can also run (and pass) these scenarios. But this is something to do still.

SpecRun

If you have followed the posts and tweets of TechTalk, you might know that we are also working on an integration test runner tool, that provides smarter (better, faster, more integrated) feedback for integration test execution.

The SpecRun beta has been updated to be compatible with SpecFlow 1.8.1. Take a look at the website: http://www.specrun.com or just grab the nuget package into your project:

Install-Package SpecRun -ProjectName MyProject

SpecFlow next steps

This post is really getting too long, so just a few bullet point for the future ideas:

  • continue with Cucumber harmonization
  • improve VS2010 step analysis (performance, stability)
  • improve step definition skeleton generation (based on the pull request of pmchugh)
  • .NET 4.0 specific enhancements
  • simplify customizations with plugin infrastructure
Download it now!

Don’t forget, that the VS integration is independent from the project dependencies, so you don’t have to wait until all your projects can upgrade to 1.8. Go ahead and download the installer for 1.8.

Please also take a look at the documentation. It’s getting better and better, but if you see any glitches in it: it’s a wiki, so just fix it!

Have fun!

Comments are closed.