1
votes

In a project using SpecFlow with this configuration:

<unitTestProvider name="MsTest.2010" />

The tests work normally when using only the default Visual Studio setup.

After installing ReSharper, the context menu commands "Run SpecFlow Scenarios" and "Debug SpecFlow Scenarios" stop working; when selected, nothing happens.

It seems this is because ReSharper sets its own test runner as default. The workaround is to open the options dialog (Tools | Options | SpecFlow | Default) and in the "Test Execution" section, set "Test Runner Tool" explicitly to "MsTest".

Unfortunately, when setting up new development machines, sometimes we forget to set this and the tests stop working after installing ReSharper, and someone has to remember this is the workaround.

The question is: would it be possible to set the "Test Runner Tool" option in the configuration file so it stays with the project, and not in the user settings? Is that what the runtimeProvider property of the unitTestProvider setting is for?

1
Not sure if you can set it in code but why not use the Resharper Test Runner?Ryan Burnham
When I tried it, the SpecFlow context menu commands to run a test for a single scenario wouldn't work. I just didn't like the experience, but that's beside the point of this question. After installing ReSharper, the SpecFlow tests just don't work anymore until you change the Test Runner Tool from the default setting, and the trick is remembering this is the problem when you are setting up a new machine and tests stop working.Fernando Correia

1 Answers

2
votes

I know you asked about VS2010, but given the age of your question, I thought I'd try it in VS2012. I was able to get SpecFlow to work with MSTest without altering the Tools\Options\SpecFlow\Test Runner Tool setting (i.e. leaving it at "Auto"):

  1. Install SpecFlow Extension to Visual Studio 2012
    • Select Tools\Extension and Updates
    • Search for "Specflow"
    • Install the extension
    • Re-start Visual Studio 2012 (SpecFlow menu items might not show up until you do this)
  2. Create new class library project (e.g. MyProject.spec)
  3. Add Specflow package via nuget
    • Right-click the project references node
    • Select Manage NuGet Packages
    • Search for "Specflow"
    • Select "Install"
  4. Configure SpecFlow
    • Open the app.config file
    • Add the following entry:
    • Right-click the project references node
    • Add the following entry inside the <specFlow> node: <unitTestProvider name="MsTest" />
  5. Create a new feature
    • Right-click the project node
    • Select Add\New Item\SpecFlow Feature File
  6. Add the unit test assembly to the project
    • Right-click the project references node
    • Select "Add Reference"
    • Search Assemblies for "Microsoft.VisualStudio.QualityTools.UnitTestFramework"
    • Add the assembly
  7. Generate Step Definitions
    • Double-click the features file to open it
    • Right click the white space at bottom of the features file
    • Select "Generate Step Definitions"
  8. Run the tests
    • Select Test Explorer\Run All

Tests should run normally at this point