1
votes

On Visual Studio 2010 Pro, I have SpecFlow and NUnit (separately) from NuGet in the same class library. The App.Config is:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
  </configSections>
  <specFlow>
    <!-- For additional details on SpecFlow configuration options see https://github.com/techtalk/SpecFlow/wiki/Configuration -->
    <unitTestProvider name="NUnit" />
  </specFlow>
</configuration>

I have the default template feature file which correctly uses NUnit as in:

        [NUnit.Framework.TestAttribute()]
        [NUnit.Framework.DescriptionAttribute("Add two numbers")]
        [NUnit.Framework.CategoryAttribute("mytag")]
        public virtual void AddTwoNumbers()
        {
            TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Add two numbers", new string[] {
                        "mytag"});
#line 7
this.ScenarioSetup(scenarioInfo);
#line 8
 testRunner.Given("I have entered 50 into the calculator");
#line 9
 testRunner.And("I have entered 70 into the calculator");
#line 10
 testRunner.When("I press add");
#line 11
 testRunner.Then("the result should be 120 on the screen");
#line hidden
            this.ScenarioCleanup();
        }

The Tools->Options->SpecFlow->TestRunnerTool is set to auto but I see NUnit isn't listed in the drop down.

When I right click on the feature file and try to run the scenarios (default scenario about calculator and two numbers from template) the pop-up dialog says "Could not find matching test runner. Please specify the test runner tool in 'Tools/Options/SpecFlow'

How do I get NUnit in that drop down? Or what else can I do to make SpecFlow run the feature file?

NUnit.Framework.dll Runtime Version v 2.0.50727 NUnit.Framework.dll Version 2.6.0.12051

TechTalk.SpecFlow.dll Runtime Version 2.0.50727 TechTalk.SpecFlow.dll Version 1.8.1.0

2
So the project (both dlls) build. Instead of using the right-click run scenario inside Visual Studio, I opened NUnit and ran the tests from there. That works.DFBerry

2 Answers

1
votes

The examples on the SpecFlow.org site (http://www.specflow.org/specflownew/ProjectSetupGuide.html) use SpecRun (http://nuget.org/packages/SpecRun.NUnit). SpecRun is one way to integrate NUnit with Visual Studio so you can execute the SpecFlow/NUnit test with a right click. SpecRun isn't a free tool. You won't see NUnit in that Tools/Options/SpecFlow dropdown, but you will see SpecRun if you've installed that tool via NuGet.

If you have ReSharper, this too is supported to run SpecFlow tests with a right click.

http://www.youtube.com/watch?v=c2ge90BWeI0

1
votes

While learning to do BDD, I have came across this blog post which was totally useful to me, and it explains every aspect, from the setup to the running tests with SpecFlow/NUnit.

Behaviour Driven Development (BDD) in .Net using SpecFlow, Selenium and NUnit

As for the SpecFlow binaries, they are not that easy to find. As I prefered to go this way, I have performed some deeper digging on the SpecFlow Website to find this page providing with the binaries: Advanced Project Setup.