Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 348
Nagendra Avatar asked May 24 '13 13:05

Nagendra


People also ask

How do I enable SpecFlow in Visual Studio?

To enable the extension in Visual Studio, select Tools | Extensions and Updates…, select the “SpecFlow for Visual Studio” extension, then select Enable.

How do I run a specific scenario in SpecFlow?

In order to execute your SpecFlow tests, you need to define the tests as Gherkin feature files, bind the steps defined in your feature files to your code, and configure a unit test provider to execute the tests. SpecFlow generates executable unit tests from your Gherkin files.

What are the two files required to execute a SpecFlow test scenario?

Files needed for test SpecFlow tests typically consist of two files, your Feature file and your Step Definitions. Your feature file is where you will be coding out your scenarios, and your step definitions file is where you define how your test behaves.


2 Answers

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.

like image 101
Tim Avatar answered Oct 22 '22 21:10

Tim


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
like image 7
Void Ray Avatar answered Oct 22 '22 23:10

Void Ray