SpecFlow+ Runner Profiles
SpecFlow+ Runner profiles (
.srprofile file extension) are XML files that determine how SpecFlow+ Runner executes your tests. This includes the behaviour 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.
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
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.
vstest.console.exe MyTestAssembly.dll /Settings:MySettings.runsettings
dotnet test -s MySettings.runsettings
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:
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:
- Right-click your project and select Add | New Item
- Browse to Installed | Visual C# Items | SpecFlow.
- Select SpecFlow+ Runner Profile (.srprofile) from the list.
- Change the name of the new item to
- 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/<Framework>) when using
SpecRun.exe for test execution *
Execution configuration element: *
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:
contentfolder of the specrun package you added to your project.
- Add the file to your project.
- Make any changes you require (see below).
SpecFlow+ Runner Profile Elements and Attributes
<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.