How to run SpecFlow tests in Visual Studio 2010?

后端 未结 8 1615
伪装坚强ぢ
伪装坚强ぢ 2020-12-23 16:57

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 fea

相关标签:
8条回答
  • 2020-12-23 17:04

    The Specflow tests are run using the NUnit (GUI), which needs to be invoked externally or alternatively TestDriven.net or Resharper can be installed to support running the tests from inside Visual Studio.

    0 讨论(0)
  • 2020-12-23 17:11

    Just to update this questions, in the latest versions of specflow you should use, (use MsTest.2010)

    <configSections> 
        <section 
           name="specFlow" 
           type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/> 
      </configSections> 
      <specFlow> 
        <unitTestProvider name="MsTest.2010" /> 
      </specFlow> 
    

    see SpecFlow wrongly using NUnit

    0 讨论(0)
  • 2020-12-23 17:14

    SpecFlow does not provide a runner itself.
    SpecFlow generates fixtures for one of the common Unit-Test-Frameworks. In SpecFlow 1.3 NUnit (default), MSTest and xUnit.net are supported (configured in the App.config).

    To run the fixtures you have to use a runner that is capable of running them. ReSharper is a very good option for a test runner that is integratied in VisualStudio, but it is not free. ReSharper gives you the "Run Unit Tests" context menu in the solution explorer, you are referring to.

    An alternative for VisualStudio integration is TestDriven.Net (also providing a context menu).

    For NUnit you can also use the runners that come with NUnit itself (there is a GUI-Runner and a commandline runner).
    For MSTest you can use the native VisualStudio integration for running tests (however I find that one a bit clumsy).
    xUnit.net also comes with its runners, however I am not familiar with them.

    Furthermore, you can use MSBuild tasks to run the fixtures ...

    0 讨论(0)
  • 2020-12-23 17:18

    Something that caught me out. I had to ensure that the Project Type was a Test Project. I had to unload the project and change the Project GUID to that of a Unit Test Project. Once I did that the SpecFlow (and any other) test in the project sprang to life

    0 讨论(0)
  • 2020-12-23 17:19

    I have created a video demonstrating how to use Specflow with VS2010 here

    0 讨论(0)
  • 2020-12-23 17:19

    You can also try Visual Nunit, an open source NUnit test runner plugin to Visual Studio 2008 and 2010. Get it using NuGet, for more info see http://www.bubblecloud.org/visualnunit

    0 讨论(0)
提交回复
热议问题