Configuring SpecFlow+ Runner Visual Studio Test Explorer Integration

SpecFlow+ Runner provides advanced integration with Visual Studio Test Explorer. After building the solution, the business readable scenario titles are displayed in Visual Studio Test Explorer.

Among others options, you can configure which SpecFlow+ Runner test profile to use, the name of the report file and custom traits applied to SpecFlow+ Runner tests to make them easier to find.

Execution defaults

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

Profile

SpecFlow+ Runner uses test profiles to configure the test suite and execution details. The Test Explorer integration looks for the file VisualStudio.srprofile in your project. If the file does not exists, the Default.srprofile file is used instead.

Processor Architecture

Unless specified in the test profile, the execution uses 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 generated using the project name and current time.

Custom configuration

To customise 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>