简体   繁体   中英

Unable to run a SpecFlow scenario from Visual Studio 2012 Ultimate Edition

I have installed Visual Studio 2012 Ultimate Edition and configured SpecFlow. I have used the following configuration to run the tests in config.xml file:

<specFlow>
<unitTestProvider name="MsTest" /> 
</specFlow>

I was able to create the testes and compile properly. But when I tried to run the scenarios from the context menu with the option "Run SpecFlow Scenarios" or "Debug SpecFlow scenarios", I am not able to see any action. It just says "Build succeeded" and nothing else happens later.

Can someone kindly explain if there is any other way of executing the scenarios?

Thanks in advance.

I already had all this configuration set, but I was still not able to get the scenarios to run from the context menu.

Until I reviewed the SpecFlow options (Tools > Options > SpecFlow) and set " VisualStudio2012 " as Test Runner Tool (under Test Execution).

For some reason it was set on "VisualStudio2010MsTest" and then the scenarios didn't run from the context menu.

Your app.config file should be:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
  </configSections>
  <specFlow>
    <unitTestProvider name="MsTest" />
  </specFlow>
</configuration>

Here is a link to SpecFlow wiki.

Then re-build your solution and you should be able to see and run the tests. You can see and run your tests from Test/Windows/Test Explorer.

Also make sure that you have a reference to: Microsoft.VisualStudio.QualityTools.UnitTestFramework from your test project. Here are the steps:

  1. Create new project: In my case MVC 4
  2. Add "Unit Test Project" to the solution
  3. Add SpecFlow nuget package to "Unit Test Project"
  4. Add one random SpecFlow feature/test 5) Run the test to make sure it works

I am aware that this is a very old post. I was having the same issue for last 4 days and finally I solved it with random StackOverflow links. To save time for other developers it may help:

  1. Change ReSharper version from 10 to 8.2
  2. Tools > Extension & Update > Search online > NUnit Test Adapter > Install
  3. Visual Studio 2013
  4. Specflow Latest version
  5. Install Unit test provider NUnit using command window of the nuget package manager. Tools-> Nuget Package Manager -> Package Manager Console. Run this in the window - Install Package specflow.Nunit
  6. Restart Visual Studio.
  7. Go to > something.Feature > right click on scenario description > run unit test OR run specflow scenario . Unit test session should appear.

Hope it will help others having the same issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM