How to run SpecFlow tests in Visual Studio 2010?

testerboy picture testerboy · Jun 6, 2010 · Viewed 24.7k times · Source

Trying to get SpecFlow running with a fresh VS2010 Professional install. Created a new console application and added references to NUnit and SpecFlow. Created a SpecFlow feature. The .feature with the default template code is created.

Now I try to run this test, but I don't understand how. When I right-click the project (at the top-level), there is no "Run test(s)" option in the mouse drop down menu. Didn't the SpecFlow install correctly, am I missing some references or some other tool I need to install?

Answer

mfloryan picture mfloryan · Jun 14, 2010

If you want to be able to run your tests directly from Visual Studio 2010 without any additional tools or extensions than you should configure SpecFlow to use MsTest as its unit test framework.

This can be done in your application configuration file with the following:

  <configSections> 
    <section 
       name="specFlow" 
       type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/> 
  </configSections> 
  <specFlow> 
    <unitTestProvider name="MsTest" /> 
    <!--
        Use this if you're running VS2010
        <unitTestProvider name="MsTest.2010" />
    -->
  </specFlow> 

The generated code-behind file will then contain MsTest tests that are recognisable by Visual Studio and can be run with the build-it test runner.

No need to use NUnit at all.