Run Specflow with Xunit but gives error nunit.framework Run Specflow with Xunit but gives error nunit.framework selenium selenium

Run Specflow with Xunit but gives error nunit.framework


This is a normal behavior since if you install Specflow nuget package it will installed based on nunit so you have to install nuget xunit for specflow

Install-Package SpecFlow.xUnit -Version 2.1.0

Update if you have done this try to add nunit package


I ran into this before but found that my problem was a mismatch between the feature text vs. the signature in the step, e.g.

Feature text:Given I have a widget id "123"

Step signature:Given I have a widgetid "123"

Ensuring all feature texts and step signatures matched solved the problem for me.

I don't know why the error was about a missing nunit dependency though, since I was using xunit.


So, I had this happen to me. It was a self-inflicted wound, as it turned out.

The problem was that, in a post-build event, I was copying the config file from the application under test to be the config file of the test project. In the post-build event for the app, I had this line, which copies the config to the Tests folder.

copy "$(ProjectDir)"\App.config "$(SolutionDir)"\ReleaseImagesWreckersTests\App.Config

The config file being copied from the application under test did not have the lines in them that tell SpecFlow to use xUnit. The copy was occurring before the SpecFlow tests were being built.Eventually, I figured it out and added these lines to my app.config for the application (assembly) under test:

    <specFlow>      <unitTestProvider name="xUnit" />   </specFlow></configuration>

After doing that, everything worked fine. The app under test was building successfully and then copying its config, with no specFlow section, over the top of the test assembly's config, which had the proper specFlow section before getting copied over.