What’s new in v1.9

Posted on:

This is our latest release, supporting Visual Studio 2008, 2010, 2012, MonoDevelop 3, SharpDevelop 4, MsBuild and NuGet. SpecFlow 1.9 feature tests can be written for the platforms .NET 3.5, 4.0, 4.5, Mono, Silverlight 3, 4, 5, Windows Phone 7.

This page contains some useful information about the new features in SpecFlow 1.9.
(New to SpecFlow? Continue reading here.)

Installation: SpecFlow IDE Integration

SpecFlow v1.9 adds support for Visual Studio 2012 integration.

Installing the IDE integration

If you previously installed the SpecFlow IDE integration for VS2010 using an MSI package, please uninstall the MSI before installing SpecFlow directly from within your IDE.

SpecFlow IDE Integration vs. Runtime

The SpecFlow IDE integration is independent of the SpecFlow runtime. We recommend always upgrading to the latest version of the IDE integration, regardless of which SpecFlow runtime you are using. SpecFlow IDE integrations are backwards compatible with SpecFlow runtimes from v1.7 on.

Installing the SpecFlow Runtime

The SpecFlow runtime library is installed per project, and you need to explicitly upgrade each project to newer runtimes. Upgrading the SpecFlow IDE integration does not automatically upgrade the SpecFlow runtime used in your projects.

We strongly recommend using NuGet to manage the SpecFlow runtime dependencies in your project, instead of manually adding the runtime references.

While we always recommend upgrading to the latest SpecFlow runtime with each release, it is possible to use older versions of the SpecFlow runtime with the latest SpecFlow IDE integration.

New in SpecFlow 1.9

Key Features

Navigation from step definition to step usage (Alt+Ctrl+Shift+S)

This new feature helps you track how your step definitions are used in feature files. Just right-click in a step definition method and select “Go To SpecFlow Step Definition Usages” from the context menu or simply press Alt+Ctrl+Shift+S (configurable). A list of usages is displayed; select one to jump to the feature files immediately.

Go To Steps in action

 

When viewing a feature file, use Alt+Ctrl+Shift+S (or select “Go To Step Definition” from the context menu) to jump back to the code.

Generate step definition skeletons from feature files (with custom templates)

Nothing is more boring then preparing the step definition skeletons for a new SpecFlow scenario. It the steps contain parameters, this takes even more time. This new feature makes this much less tedious!

Select “Generate Step Definitions” from the context menu in the feature file. A dialogue is displayed and guides you through the process of creating a new binding class with step definitions for the selected unbound steps. You don’t need to worry 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).

Generate step definition dialog

 

The same skeleton generator engine is used by the SpecFlow runtime (when you execute a scenario with unbound steps) and also in the “Go To Definition” command. You can specify the default generation style in the app.config.

If you want to include a custom using statement or a base class declaration in the generated step definition skeletons, you can also customize the templates! Just place a text file called SkeletonTemplates.sftemplate in the SpecFlow folder in your local app data, and override the necessary templates. You can read more about the format here.

Sample skeleton template for generating the classes in C#

 

Highlight unbound steps and step parameters in the editor (beta)

Do you want to check the binding status of the steps in a scenario? Do you want to improve the readability of scenarios by highlighting parameters? You can now do this with the new editor feature: parameters in bound steps are highlighted and unbound steps are displayed in purple. You can of course configure the colors.

Highlight unbound steps and step parameters in the editor

 

Note: This is a beta feature. If you experience issues, you can switch it off in Visual Studio under Tools/Options/SpecFlow. Unbound step templates in scenario outlines cannot currently be detected.

Step Definitions without Regular Expressions (beta)

If you believe that regular expressions are too complex and technical for defining step definitions, or simply want to write (and maintain) less code, you should check this feature out.

You can now define step definitions without regular expressions for steps that only need simple text and parameter matching. Simply name your method with underscores between words or using Pascal-case syntax and annotate them with an empty [Given], [When] or [Then] attribute: SpecFlow will recognize them as step definitions! You can also refer to parameters by index or by parameter name. For more details, see here.

Calculator step definition without Regex

 

You can define your step definitions without regex, but you can still use regex! The regex-style definition will always be supported for special cases and for regex-loving geeks.

Note: We are still collecting feedback about how this feature would be best implemented, in particular regarding parameter substitution. We may need to fine-tune the rules in upcoming versions.

F# step definitions

F# is a popular functional language on the .NET platform. You can now take the advantages of the F# language to write step definitions: you can define regex-named F# functions for your steps. Simply put the regex between double backticks:

Step definitions in F# with regex method names

 

Note: You need to create a C# or VB project to host the feature files and configure your F# project(s) as external binding assemblies. You can read more about F# SpecFlow support here.

Visual Studio 2012 generic test runner support

The SpecFlow IDE integration now supports triggering the execution of SpecFlow feature files for the new VS2012 test runner infrastructure. As a result, the following test runner infrastructure is now supported by SpecFlow: VS2012, ReSharper, SpecRun, MS-Test Runner (in VS2010).

SpecFlow can automatically detect and use the new test runner in VS2012.
You can execute SpecFlow scenarios with the new VS2012 test runner on all supported unit testing platforms (e.g. NUnit, xUnit, MS-Test), and jump from the test explorer directly to the related feature files.

SpecFlow scenarios executed with the VS2012 test runner

 

Additional New Features

New and updated NuGet packages
all based on the SpecFlow package, making configuration easy.

  • SpecFlow.xUnit – setup SpecFlow with xUnit in one step
  • SpecFlow.NUnit – following the new packaging model of NUnit, this package is for using SpecFlow with the NUnit runtime (but not with the NUnit runners)
  • SpecFlow.NUnit.Runners – this package contains the necessary add-on for the NUnit runners, and should be used in addition to the SpecFlow.NUnit package
  • SpecFlow.CustomPlugin – for developing custom plugins (e.g. custom generators) for SpecFlow
Plugin Infrastructure
SpecFlow provides improved plugin infrastructure for customization.
Better Guid support in bindings
You can have Guid parameters in the step definition methods and you can provide partially specified Guids (which are filled with trailing zeroes) as step arguments or table conversions.
Other Visual Studio Editor Enhancements
  • Comment/uncomment feature file lines using the standard Visual Studio or ReSharper commands
  • Cached step analysis for faster solution startup – the result of the step analysis are stored in the local temp folder so that only an incremental analysis has to be performed when opening the solution
  • Resolved conflicts with SharePoint feature files
  • Support for ReSharper command shortcuts (when ReSharper is installed): commenting, navigation, test execution
  • Support for tracking files changed outside of Visual Studio (e.g. after a git pull)
  • Analyzing bindings in assembly references

For a complete list of features and bugfixes, check out our detailed changelog.

Redesign: SpecFlow Logo and Website

The SpecFlow logo has also been revamped with this release.

We are currently working on relaunching of the SpecFlow website:

Explore the SpecFlow eco-system

Check out the products that make SpecFlow even more powerful!

  • SpecFlow+ Runner (formerly known as SpecRun) – smart, integrated test runner for SpecFlow
  • SpecFlow+ Excel – collaborate with business partners using Given/When/Then directly in Excel
  • SpecLog – build up a living documentation based on SpecFlow
  • Contact us if you want to be listed here!

Want to learn more?