Configuring SpecFlow for XUnit using new-style csproj
by Matthew Adams
While you cannot yet use SpecFlow with netcore or netstandard projects, you can use new-style (dotnet) test projects that target net461, and reference netstandard projects-under-test from there.
We like to use XUnit as the underlying test provider in this scenario, and we do the following:
Install the current SpecFlow VS 2017 extension into VS 2017
Create a DotNetCore XUnit test project and perform any package updates offered to you (this handily sets up the VS2017 test environment properly)
Change the <TargetFramework> in the .csproj file from dotnetcore2.x to net461 (or 462, or whatever, but 461 is a good safe lowest common denominator for most scenarios)
Add the SpecFlow.XUnit package to your project
Add an app.config file to configure XUnit code generation
You can now add feature files and generate steps in the normal way.
If you enjoyed this post, please consider sharing it on social media using the buttons below. Thanks!
Matthew was CTO of a venture-backed technology start-up in the UK & US for 10 years, and is now a Founder of Endjin Ltd, which provides technology strategy, experience and development services to its clients who are seeking to take advantage of Microsoft Azure and the Cloud.
You can follow Matthew on twitter.