Search code examples
c#visual-studiomstestspecflowrunsettings

How to use Specflow srsprofile in mstest runsettings


One of my projects uses spec flow + MSTest + MSBuildGeneration tool. I have few filter tags defined in my srsprofile and created a runsettings file something like below

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <!-- Configurations that affect the Test Framework -->
  <RunConfiguration>
    <!-- Path relative to solution directory -->
    <!--<ResultsDirectory>..\..\..\Reports\LastRun\</ResultsDirectory>-->

    <!-- [x86] | x64  
      - You can also change it from menu Test, Test Settings, Default Processor Architecture -->
    <TargetPlatform>x86</TargetPlatform>

    <!-- Framework35 | [Framework40] | Framework45 -->
    <TargetFrameworkVersion>Framework46</TargetFrameworkVersion>
  </RunConfiguration>

  <!-- test adapter -->
  <MsTest>
    <Profile>sample.srprofile</Profile>
  </MsTest>
</RunSettings>

UnitTest Provider

  <specFlow>
    <stepAssemblies>
      <stepAssembly assembly="MyProject.Steps" />
    </stepAssemblies>
    <unitTestProvider name="MsTest" />
    <!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config -->
  </specFlow>

Since I am using MSTest and not SpecRun, the adapter I believe should be MsTest, but the tests are not showing up in the test explorer in visual studio 2017 for the defined filters. am I doing it wrong ? Is there a different way to use filter tags in srsprofile for mstest ?


Solution

  • The srProfile- File is a feature of the SpecFlow+ Runner (aka SpecRun). The features of it are only available there. You can't use it with MSTest.

    As far as I found out, there is no way to set filter in the runsettings file at all.

    Docs for it are: https://learn.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2019


    Full disclosure: I am the community manager of SpecFlow and SpecFlow+