Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get SpecFlow working with xUnit.net as the test runner

I'm trying to use xUnit.net as the test runner for SpecFlow. The SpecFlow 1.2 binaries from the official download area don't contain an xUnit.net provider but the master branch on GitHub has one, so I build SpecFlow.Core.dll from that. I'm using xUnit.net 1.5.

However, when I change the unitTestProvider name in the app.config in my spec project, I get a null reference custom tool error and the generated .feature.cs file is the single line:

Object reference not set to an instance of an object.

Has anyone succeeded in getting SpecFlow to work with xUnit.net? If so, how?

like image 983
Mike Scott Avatar asked Apr 27 '10 16:04

Mike Scott


1 Answers

I just ran into the same problem and found the answer. Just use the lates dist of SpecFlow, I'm using 1.3.5.2. Then all you have to do is to add a reference to xUnit.dll and to create an App.config file to your Specs project with this configuration:

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

    <specFlow>
       <language feature="en-US" />
         <unitTestProvider name="xUnit" />

         <runtime detectAmbiguousMatches="true" stopAtFirstError="false"
                 missingOrPendingStepsOutcome="Inconclusive" />

         <trace traceSuccessfulSteps="true" traceTimings="false"
             minTracedDuration="0:0:0.1" />
    </specFlow>
  </configuration>

The part that's doing the trick here is the unitTestProvider element.

like image 83
Gargamel Avatar answered Sep 28 '22 05:09

Gargamel