This repo is now archived because SpecFlow has caught up! A huge thanks to the many contributors! 🍻
As at the time of writing (September 2016), the SpecFlow for Visual Studio 2015
extension does not play well with .NET Core projects.
Wait for the VS extension to support .NET Core projects. In the meantime, I present...
Update your project:
-
Include SpecFlow and your test framework of choice:
-
<ItemGroup> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" /> <PackageReference Include="SpecFlow" Version="2.1.0" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" /> <PackageReference Include="xunit" Version="2.2.0" /> </ItemGroup>
-
NUnit (Experimental):
<ItemGroup> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" /> <PackageReference Include="SpecFlow" Version="2.1.0" /> <PackageReference Include="NUnit" Version="3.8.1" /> <PackageReference Include="dotnet-test-nunit" Version="3.4.0-beta-2" /> </ItemGroup>
-
MsTest (Experimental):
<ItemGroup> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" /> <PackageReference Include="SpecFlow" Version="2.1.0" /> <PackageReference Include="MSTest.TestAdapter" Version="1.1.18" /> <PackageReference Include="MSTest.TestFramework" Version="1.1.18" /> </ItemGroup>
-
-
Include
SpecFlow.NetCore
:<ItemGroup> <DotNetCliToolReference Include="SpecFlow.NetCore" Version="1.3.5" /> </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.
This has been tested on Windows, Ubuntu and macOS (High Sierra). It works in exactly the same way except it doesn’t use DotNetCli because it doesn’t work cross platform. Instead we call dotnet-SpecFlow.NetCore.exe directly from the package, this is why we need an extra PackageReference to SpecFlow.NetCore.
You also need to reference SpecFlow 2.2 or higher due to a Mono specific bug in SpecFlow.
<PropertyGroup>
<SpecFlowNetCoreVersion>1.3.2</SpecFlowNetCoreVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SpecFlow.NetCore" Version="$(SpecFlowNetCoreVersion)" />
<PackageReference Include="SpecFlow" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="xunit" Version="2.2.0" />
</ItemGroup>
<Target Name="PrecompileScript" BeforeTargets="BeforeBuild">
<Exec Command="mono $(NuGetPackageRoot)specflow.netcore/$(SpecFlowNetCoreVersion)/lib/$(TargetFramework)/dotnet-SpecFlow.NetCore.exe" />
</Target>
SpecFlow itself is currently limited to Windows platforms with full .NET Framework v4.5.1+. This means that two of the most common target frameworks are unsupported:
(unsupported).NET Standard
(unsupported).NET Core Application
.NET Framework
For .NET Framework
, the following Target Framework Monikers (TFMs) are officially supported:
net46
net461
TFMs of net451
and above should support SpecFlow and this project, but have not been officially tested.
If you build the samples solution, you should see .feature.cs
files and an app.config
being generated for each test framework.
- 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