Updating to SpecFlow 2

IMPORTANT INFORMATION

Changelogs

You can find an overview of the new features in SpecFlow 2.0 here. The full changelog is on GitHub
A list of the changes in SpecFlow+ Runner 1.3 is available here.

Make a Backup!

Before upgrading to the latest version, ensure you have a backup of your project (either locally or in a source control system).

.NET Framework 4.5 or Higher Required

SpecFlow 2 targets .NET 4.5, i.e. it works with .NET 4.5 or higher. You should therefore not upgrade to the new version in projects using earlier versions of the .NET framework. In this case, you should continue using SpecFlow 1.9 until you are ready to move to .NET 4.5.

Visual Studio Integration

The Visual Studio integration for SpecFlow has not been updated. The new versions of SpecFlow and SpecFlow+ work with the previous release. This means that you can also migrate your project individually, as projects that continue using previous version will to continue to work alongside upgraded projects.

Upgrading SpecFlow+ without Upgrading SpecFlow

If you are using SpecFlow+ and want to continue using SpecFlow 1.8 or 1.9, you can choose to only upgrade the SpecRun for SpecFlow 1.9 or SpecRun for SpecFlow 1.8 package. This will update SpecFlow+ while retaining your old version of SpecFlow.

SpecFlow+ Runner Report Templates

The Razor engine used to generate SpecFlow+ reports has been updated from 2.1.0 to 3.6.1. As a result of the change in the Razor syntax between these versions, customised report templates may no longer work without being updated to the new syntax. If you are using intellisense, you will also need to update the DLLs to the new version. More details can be found here.

TFS XAML Build Agents with Different Versions of SpecFlow+

If you are using TFS XAML builds and plan on using SpecFlow+ Runner 1.2 and 1.3 in parallel with different projects, you need to ensure that the different runner versions target different build agents. More details can be found here.

Updating SpecFlow Only

Upgrading from SpecFlow 1.9 to SpecFlow 2

To upgrade from SpecFlow 1.9 to SpecFlow 2:

  1. Open your solution, and check that it compiles, all tests are discovered and that all source files have been committed.
  2. Right-click on your SpecFlow projects and select Properties. Ensure that the Target framework is set to .NET Framework 4.5 (or higher).
  3. Right-click on your solution and select Manage NuGet Packages for Solution.
  4. Switch to Updates in the list on the left and locate SpecFlow in the list of packages. Use the search box to restrict the listed packages if necessary.
  5. Select the SpecFlow package in the list and click on Update.
  6. Depending on your version of Visual Studio, you may be prompted whether you wish to update your feature files. Choose No, as you will want to wait for the installation to complete before updating the feature files (see below).
  7. Open app.config and review the changes. If you see duplicated settings, remove these or simply undo the changes.
  8. Close and reopen your solution.
  9. Once SpecFlow has updated, you should be able to compile your project. However, to take full advantage of SpecFlow 2, you should regenerate the feature files:
    • Open a feature file in your solution. If you see a popup informing you that the feature files were generated with an earlier version of SpecFlow, click on Yes to regenerate these files. Depending on the size of your project, this may take a while.
    • If you are using an earlier version of Visual Studio, you need to force the feature files to be regenerated. Right-click on your project, and select Regenerate Feature Files from the menu.
  10. To confirm that the feature file has been regenerated, open the .cs file relating to one of your feature files. You should see SpecFlow version 2 listed in the header:
    generated code
  11. Build your solution and execute your tests.

Updating SpecFlow and SpecFlow+ Runner

If you want to update both SpecFlow to version 2 and SpecFlow+ to 1.3, the easiest way to do this is to simply upgrade the SpecRun for SpecFlow package. This automatically updates SpecFlow as well.

To update SpecFlow and SpecFlow+:

  1. Open your solution, and check that it compiles, all tests are discovered and that all source files have been committed.
  2. Right-click on your SpecFlow projects and select Properties. Ensure that the Target framework is set to .NET Framework 4.5 (or higher).
  3. Right-click on your solution and select Manage NuGet Packages for Solution.
  4. Switch to Updates in the list on the left and locate SpecRun for SpecFlow 2.0.0 in the list of packages. Use the search box to restrict the listed packages if necessary.
  5. Select the SpecRun package in the list and click on Update.
    The dependent packages (SpecRun Runner and SpecFlow 2) are updated as well.
  6. If your project’s SpecRun profile is named Default.srprofile, you will be asked if you wish to overwrite the file in your project. Do not overwrite this file if you have made changes to your profile!
  7. If you are using a version of Visual Studio earlier than VS 2015:
    Open packages.config (under .nuget in the Solution Explorer) and remove the line referencing SpecFlow 1.2:
    <package id”=”SpecRun.Runner” version=”1.2.0” />
    Note: This file no longer exists in Visual Studio 2015.
  8. Depending on your version of Visual Studio, you may be prompted whether you wish to update your feature files. Choose No, as you will want to wait for the installation to complete before updating the feature files (see below).
  9. Open app.config and review the changes. If you see duplicated settings, remove these or simply undo the changes.
  10. Open the \packages directory of your project and delete and SpecFlow+ 1.2 folders (SpecFlow.Plus, SpecRun).
  11. Restart Visual Studio.
  12. Once SpecFlow has updated, you should be able to compile your project. However, to take full advantage of SpecFlow 2, you should regenerate the feature files:
    • Open a feature file in your solution. If you see a popup informing you that the feature files were generated with an earlier version of SpecFlow, click on Yes to regenerate these files. Depending on the size of your project, this may take a while.
    • If you are using an earlier version of Visual Studio, you need to force the feature files to be regenerated. Right-click on your project, and select Regenerate Feature Files from the menu.
  13. To confirm that the feature file has been regenerated, open the .cs file relating to one of your feature files. You should see SpecFlow version 2 listed in the header:
    generated code
  14. Build your solution and execute your tests.

Troubleshooting

If you have updated SpecFlow and SpecFlow+ and are receiving error messages and/or your tests are not being discovered, please check the following:

  • Ensure that your project is set up to target at least .NET 4.5 (right-click on your project, select Properties and check the entry under Target framework).
  • Ensure that you have deleted any SpecFlow+ 1.2 directories in your project’s \packages directory.
  • If you are using not using Visual Studio 2015, ensure that you have updated packages.config and removed any references to SpecFlow+ 1.2.
  • If you have not restarted Visual Studio since updating the package, restart Visual Studio.
  • If you are using intellisense with customised report templates, update the DLLs in your project to the new version.

Updating SpecFlow+ Runner Only

Updating to SpecFlow+ 1.3 with SpecFlow 1.9

To update only SpecFlow+ to 1.3 and continue using SpecFlow 1.9:

  1. Open your solution, and check that it compiles, all tests are discovered and that all source files have been committed.
  2. Right-click on your solution and select Manage NuGet Packages for Solution.
  3. Switch to Installed packages in the list on the left and locate SpecRun for SpecFlow 1.9.0 in the list of packages. Use the search box to restrict the listed packages if necessary.
  4. Click on Manage and disable the package for all project using the solution’s check box.
  5. Click on OK to remove the old version of SpecRun from your projects. You will be prompted whether you want to uninstall SpecFlow 1.9.0 as well. Answer No to this prompt.
  6. Switch to Online in the list on the left and search for “SpecRun”. Locate SpecRun for SpecFlow 1.9.0 and click on Install.
    Note: Despite the name, this is a different package from the one you uninstalled previously.The dependent package (SpecRun Runner) is updated as well.
  7. If your project’s SpecRun profile is named Default.srprofile, you will be asked if you wish to overwrite the file in your project. You may be asked if you want to override additional files, such as the report template.Do not overwrite these files if you have made changes to them!
  8. If you are using a version of Visual Studio earlier than VS 2015:
    Open packages.config (under .nuget in the Solution Explorer) and remove the line referencing SpecFlow 1.2:
    <package id”=”SpecRun.Runner” version=”1.2.0” />
    Note: This file no longer exists in Visual Studio 2015.
  9. Open the \packages directory of your project and delete and SpecFlow+ 1.2 folders (SpecFlow.Plus, SpecRun).
  10. Restart Visual Studio.
  11. Build your solution and execute your tests.

Updating to SpecFlow+ 1.3 with SpecFlow 1.9

To update only SpecFlow+ to 1.3 and continue using SpecFlow 1.8:

  1. Open your solution, and check that it compiles and all tests are discovered and that all source files have been committed.
  2. Right-click on your solution and select Manage NuGet Packages for Solution.
  3. Switch to Updates in the list on the left and locate SpecRun for SpecFlow 1.8.0 in the list of packages. Use the search box to restrict the listed packages if necessary.
  4. Click on Update to update the package. The dependent package (SpecRun Runner) is updated as well.
  5. If your project’s SpecRun profile is named Default.srprofile, you will be asked if you wish to overwrite the file in your project. You may be asked if you want to override additional files. Do not overwrite these files if you have made changes to them!
  6. If you are using a version of Visual Studio earlier than VS 2015:
    Open packages.config (under .nuget in the Solution Explorer) and remove the line referencing SpecFlow 1.2:
    <package id”=”SpecRun.Runner” version=”1.2.0” />
    Note: This file no longer exists in Visual Studio 2015.
  7. Open the \packages directory of your project and delete and SpecFlow+ 1.2 folders (SpecFlow.Plus, SpecRun).
  8. Restart Visual Studio.
  9. Build your solution and execute your tests.

Troubleshooting

If you have updated the SpecFlow+ Runner and are receiving error messages and/or your tests are not being discovered, please check the following:

  • Ensure that you have deleted any SpecFlow+ 1.2 directories in your project’s \packages directory.
  • If you are using not using Visual Sutdio 2015, ensure that you have updated packages.config and removed any references to SpecFlow+ 1.2.
  • If you have not restarted Visual Studio since updating the package, restart Visual Studio.
  • If you are using intellisense with customised report templates, update the DLLs in your project to the new version.