How to get SpecFlow to work with xUnit.net as a test runner

I am trying to use xUnit.net as a test runner for SpecFlow. The SpecFlow 1.2 binaries from the official download area do not contain the xUnit.net provider, but the main branch on GitHub has one, so I create SpecFlow.Core.dll from this. I am using xUnit.net 1.5.

However, when I change the name unitTestProvider to app.config in my specification project, I get a blank link for user tool errors and the generated .feature.cs file is one 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?

+4
source share
3 answers

The SpecFlow-Example repository has an example for SpecFlow with xUnit:

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

To run it, you need to build SpecFlow from the latest sources on github (main branch). You must also install SpecFlow 1.2 to ensure proper VisualStudio integration. Then replace all the assemblies in the installation directory (by default, Program Files (x86) \ TechTalk \ SpecFlow) with the assemblies created from the source.

After that, you can create and run the aforementioned SpecFlow-Example project.

Hope this helps?

+2
source

I ran into the same problem and found the answer. Just use Lates dist SpecFlow, I use 1.3.5.2. Then all you have to do is add the link to xUnit.dll and create the App.config file for 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 does the trick here is the unitTestProvider element.

+10
source

Source: https://habr.com/ru/post/1308154/


All Articles