views:

375

answers:

4

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?

+1  A: 

There is an example for SpecFlow with xUnit in the SpecFlow-Example repository:

http://github.com/techtalk/SpecFlow-Examples/tree/master/BowlingKata/BowlingKata-XUnit

In order to run it, you have to build SpecFlow from the latest sources on github (master branch). You also should have installed SpecFlow 1.2 in order to get proper VisualStudio integration. Then replace all the assemblies in you installation directory (default Program Files (x86)\TechTalk\SpecFlow) with the assemblies built from source.

After this you should be able to build and run the above SpecFlow-Example project.

Hope this helps?

jbandi
Do I need to download and install the VS integration stuff to build from source? Also, I don't have VB installed. So the VS integration project isn't available in the solution and the tests fail because they can't load ExternalStepsVB.
Mike Scott
Also, VS can't find the references to TechTalk.SpecFlow.dll and xunit.dll in the bowling kata xunit example.
Mike Scott
I've removed the missing references and added correct ones, but running the tests in TD.Net gives null reference exceptions originating in SpecFlow.ObjectContainer. It seems that the code is missing null checks :-(
Mike Scott
Thanks. The recent commits on GitHub have fixed it.
Mike Scott
A: 

Hi Mike, Just run into the save issue trying to use specflow and xUnit. If its not an issue, can you provide a download like to your build for xunit support?

emmanuel buah
+3  A: 

As of SpecFlow 1.3, xUnit is supported! http://groups.google.com/group/specflow/browse_thread/thread/e3d593a52aa17a15

Danny Douglass
+1  A: 

Hi, 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.

Gargamel
Thanks, but I commented that it was fixed on 4 May 2010.
Mike Scott