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

Configure Visual Studio Test Explorer Integration

SpecFlow+ Runner provides tighter integration with the Visual Studio Test Explorer. Once you have built your solution, your tests are displayed with their business-readable scenario titles in the Test Explorer.

When running tests from the Test Explorer window, tests are executed using the following defaults.

Profile

SpecFlow+ Runner uses test profiles to configure a variety of settings that determine how tests are executed. By default, the Test Explorer uses the VisualStudio.srprofile file in your project, if present. If the file does not exists, the Default.srprofile file is used instead.

You can specify a different profile in your .runsettings file (see below).

Processor Architecture

Unless specified otherwise in the test profile, tests are executed using the test processor architecture setting in Visual Studio. By default, this is set to x86 in Visual Studio.

To change this setting in Visual Studio, select Test|Test Settings|Default Processor Architecture| from the menu and choose the desired architecture (X86 or X64).

Report file

By default, the name of the report generated by SpecFlow+ Runner is based on the project name and current time.

Custom Configuration

To customize your configuration, you need to use a combination of the Visual Studio test settings file and the SpecFlow+ Runner test profile. This requires the following steps:

  1. Add a test settings file to your project based on the template located in packages/SpecRun.Runner.{version}/docs/Sample.runsettings using Add Existing Item… in Visual Studio.
  2. Change the settings in the .runsettings file as needed (see below).
  3. Select Test|Test Settings|Select Test Settings from the menu and choose your file.

General run settings

SpecFlow+ Runner uses the following Visual Studio general settings. You can find details about these settings on MSDN.

  • ResultsDirectory: The directory where test results are placed.
  • TargetFrameworkVersion: Default target framework version (to test using the .NET 3.5 framework, set the TargetFrameworkVersion to Framework40 and use the SpecFlow+ Runner profile to specify .NET 3.5)
  • TargetPlatform: Default processor architecture (can be overridden in the SpecFlow+ Runner profile)

Sample run settings file with general settings:

<RunSettings>
  <RunConfiguration>
    <ResultsDirectory>.\TestResults</ResultsDirectory>
    <TargetPlatform>x86</TargetPlatform>
    <TargetFrameworkVersion>Framework40</TargetFrameworkVersion>
  </RunConfiguration>
  ...
</RunSettings>

SpecFlow+ Runner settings

SpecFlow+ Runner settings can be specified in the <SpecRun> element of your .runsettings file. See the “Execution defaults” section for information on the default settings.

Available options:

  • Profile: Specifies the SpecFlow+ Runner test profile to use.
  • ReportFile: Specifies the name of the report file.
  • GenerateSpecRunTrait: If set to true, all SpecFlow+ Runner tests are marked with the SpecRun trait. This can be useful for distinguishing SpecFlow+ Runner tests from unit tests in the Test Explorer window.
  • GenerateFeatureTrait: If set to true, all SpecFlow+ Runner tests are marked with traits using the feature title. The “Group by Class” view of the Test Explorer window can also be used to group tests by feature.

Sample .runsettings file with SpecFlow+ Runner settings:

<RunSettings>
  <RunConfiguration>
    ...
  </RunConfiguration>

  <!-- Configurations for SpecFlow+ Runner -->
  <SpecRun>
    <Profile>MyProfile.srprofile</Profile>
    <ReportFile>CustomReport.html</ReportFile>
    <GenerateSpecRunTrait>false</GenerateSpecRunTrait>
    <GenerateFeatureTrait>false</GenerateFeatureTrait>
  </SpecRun>
</RunSettings>