The SpecFlow+ Runner is out of maintenance. Read more about it here.

Profiles

SpecFlow+ Runner profiles (.srprofile file extension) are XML files that determine how SpecFlow+ Runner executes your tests. This includes the behavior when tests fail (e.g. repeat the test, abort after X failed tests), defining various target environments for your tests (e.g. different web browsers or x64/x86), enabling multi-threading, configuring folder and file paths and applying transformations to your default configuration file in order to change the transform the configuration file for different target environments.

Using Profiles

The name of the profile file used by your project is defined using the <Profile> tag in your .runsettings file. By default, SpecFlow+ Runner expects a file called Default.srprofile.

Note: If you use a .runsettings file to specify your profile and are executing tests in Visual Studio, make sure you have set the settings file correctly in Visual Studio. Select Test ]( Select Settings File from the menu in Visual Studio and select your .runsettings file to do so. If your .runsettings file is not referenced correctly, your tests will run using Default.srprofile, and the results may not be the ones you expect.

If you need to regularly switch between profiles from the command line, you can do so by adding a .runsettings file for each profile, and specifying the profile as a parameter from the command line.

Examples:

vstest.console.exe MyTestAssembly.dll /Settings:MySettings.runsettings

dotnet test -s MySettings.runsettings

Default Profile

This section only affects SpecFlow+ Runner until version 3.0.284. For default values used in later SpecFlow+ Runner versions, see the section below.

The default profile is relatively basic, and includes your project name, ID and various default settings. It also includes a commented out section that you can use to transform the database connection string in your configuration file in order to access a different database instance.

You either need to add this file to your project manually, or it is added manually, depending on the version of SpecFlow+ you are using:

SpecFlow+ 3

When using a version of SpecFlow+ Runner higher than 3.0.284, you do not have to manually add a Default.srprofile to the project. This affects all project formats and target framework versions.

Until SpecFlow+ Runner version 3.0.284, you need to manually add a profile to your project. To do so:

  1. Right-click your project and select Add ]( New Item
  2. Browse to Installed ]( Visual C# Items ]( SpecFlow.
  3. Select SpecFlow+ Runner Profile (.srprofile) from the list.
  4. Change the name of the new item to Default.srprofile.
  5. Click on Add.

Earlier versions of SpecFlow+

Prior to SpecFlow 3, a Default.srprofile is automatically added to your Visual Studio project when you add the NuGet package to your solution.

Default values used by SpecFlow+ Runner after version 3.0.284

The following behaviors are used by default if no Default.srprofile could be found:

  • Search for tests in the base folder (i.e. bin/Debug or bin/Debug/<Framework>) when using SpecRun.exe for test execution
  • Execution configuration element:
    • testThreadCount is 1
    • stopAfterFailures is 3
    • testSchedulingMode is Sequential

If you intend to use other values, you have to add a .srprofile file to the project.

Adding a Profile to Your Project (.NET Core)

The following section affects only SpecFlow+ Runner versions until 3.0.284.

When working with .NET Core projects, the default profile (Default.srprofile) is not automatically added to new SpecFlow+ projects. You need to add the file manually:

  1. Locate Default.srprofile in the content folder of the specrun package you added to your project.
  2. Add the file to your project.
  3. Make any changes you require (see below).

SpecFlow+ Runner Profile Elements and Attributes

The <TestProfile> element is a container for the remaining elements.

The following XML elements and attributes are available:

You can also use a number of Placeholders in your profile.