As at the time of writing (September 2016), the SpecFlow for Visual Studio 2015
extension does not play well with .NET Core projects (.xproj
).
Updated Feb 2017 to work with the 1.0.0-rc4 tooling and .csproj
Wait for the VS extension to support .NET Core projects. In the meantime, I present...
Update your project.json
:
Update your test projects .csproj or add a reference to the project in Visual Studio 2017
- Include your testrunner of choice
-
xUnit: Reference to the xunit package is used to identify xunit as the testrunner
<ItemGroup> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170106-08" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-beta5-build1225" /> <PackageReference Include="SpecFlow" Version="2.1.0" /> <PackageReference Include="xunit" Version="2.2.0-beta5-build3474" /> </ItemGroup>
-
NUnit 3 (Experimental): eference to the NUnit package is used to identify nunit as the testrunner
<ItemGroup> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170106-08" /> <PackageReference Include="SpecFlow" Version="2.1.0" /> <PackageReference Include="NUnit" Version="3.4.1" /> <PackageReference Include="dotnet-test-nunit" Version="3.4.0-beta-2" /> </ItemGroup>
-
MsTest (Experimental): Reference to the MSTest.TestFramework package is used to identify mstest as the testrunner
<ItemGroup> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170106-08" /> <PackageReference Include="MSTest.TestAdapter" Version="1.1.8-rc" /> <PackageReference Include="SpecFlow" Version="2.1.0" /> <PackageReference Include="MSTest.TestFramework" Version="1.0.8-rc" /> </ItemGroup>
- Include
SpecFlow.NetCore
:
<ItemGroup>
<DotNetCliToolReference Include="SpecFlow.NetCore" Version="1.0.0-rc8" />
</ItemGroup>
- Add a
precompile
script:
<Target Name="PrecompileScript" BeforeTargets="BeforeBuild">
<Exec Command="dotnet SpecFlow.NetCore" />
</Target>
- Build for your tests to be discovered. Note: there is a bug with the .NET Core CLI requiring a second build for newly added files to be discovered.
If you build the samples solution, you should see .feature.cs
files and an app.config
being generated for each test framework.
netcoreapp1.0
net46
net461
- xUnit
- NUnit 3 - Experimental support added by the community.
- MsTest - Experimental support added by the community.
- SpecFlow Issue 471: Auto generation of
feature.cs
fails when using MSBuild that comes with VS2015 - SpecFlow Issue 457: SpecFlow "Generate Step Definition" context menu missing in VS2015
- SpecFlow Google Group discussing VS2015 & DNX