|
4 | 4 |
|
5 | 5 | As at the time of writing (September 2016), the `SpecFlow for Visual Studio 2015` extension does not play well with .NET Core projects (`.xproj`). |
6 | 6 |
|
| 7 | +**Updated Feb 2017 to work with the 1.0.0-rc4 tooling and .csproj** |
| 8 | + |
7 | 9 | ## The solution |
8 | 10 |
|
9 | 11 | Wait for the VS extension to support .NET Core projects. In the meantime, I present... |
10 | 12 |
|
11 | 13 | ## The (hopefully temporary) solution |
12 | 14 |
|
13 | 15 | Update your `project.json`: |
| 16 | +Update your test projects .csproj or add a reference to the project in Visual Studio 2017 |
14 | 17 |
|
15 | 18 | 0. Include your testrunner of choice |
16 | 19 |
|
17 | 20 | * [xUnit](https://github.com/xunit/dotnet-test-xunit): |
18 | | - |
19 | | - ```json |
20 | | - "dependencies": { |
21 | | - "xunit": "2.1.0", |
22 | | - "dotnet-test-xunit": "1.0.0-*" |
23 | | - }, |
24 | | - "testRunner": "xunit" |
| 21 | + Reference to the xunit package is used to identify xunit as the testrunner |
| 22 | + |
| 23 | + ```xml |
| 24 | + <ItemGroup> |
| 25 | + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170106-08" /> |
| 26 | + <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-beta5-build1225" /> |
| 27 | + <PackageReference Include="SpecFlow" Version="2.1.0" /> |
| 28 | + <PackageReference Include="xunit" Version="2.2.0-beta5-build3474" /> |
| 29 | + </ItemGroup> |
25 | 30 | ``` |
26 | 31 |
|
27 | 32 | * [NUnit 3](https://github.com/nunit/dotnet-test-nunit) _(Experimental)_: |
28 | | - ```json |
29 | | - "dependencies": { |
30 | | - "NUnit": "3.4.1", |
31 | | - "dotnet-test-nunit": "3.4.0-beta-2" |
32 | | - }, |
33 | | - "testRunner": "nunit" |
| 33 | + eference to the NUnit package is used to identify nunit as the testrunner |
| 34 | + ```xml |
| 35 | + <ItemGroup> |
| 36 | + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170106-08" /> |
| 37 | + <PackageReference Include="SpecFlow" Version="2.1.0" /> |
| 38 | + <PackageReference Include="NUnit" Version="3.4.1" /> |
| 39 | + <PackageReference Include="dotnet-test-nunit" Version="3.4.0-beta-2" /> |
| 40 | + </ItemGroup> |
34 | 41 | ``` |
35 | 42 |
|
36 | 43 | * [MsTest](https://www.nuget.org/packages/dotnet-test-mstest/1.1.1-preview) _(Experimental)_: |
37 | | - ```json |
38 | | - "dependencies": { |
39 | | - "dotnet-test-mstest": "1.1.1-preview", |
40 | | - "MSTest.TestFramework": "1.0.4-preview" |
41 | | - }, |
42 | | - "testRunner": "mstest" |
| 44 | + Reference to the MSTest.TestFramework package is used to identify mstest as the testrunner |
| 45 | + ```xml |
| 46 | + <ItemGroup> |
| 47 | + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170106-08" /> |
| 48 | + <PackageReference Include="MSTest.TestAdapter" Version="1.1.8-rc" /> |
| 49 | + <PackageReference Include="SpecFlow" Version="2.1.0" /> |
| 50 | + <PackageReference Include="MSTest.TestFramework" Version="1.0.8-rc" /> |
| 51 | + </ItemGroup> |
43 | 52 | ``` |
44 | 53 |
|
45 | 54 | 0. Include [`SpecFlow.NetCore`](https://www.nuget.org/packages/SpecFlow.NetCore): |
46 | 55 |
|
47 | | - ```json |
48 | | - "tools": { |
49 | | - "SpecFlow.NetCore": "1.0.0-*" |
50 | | - } |
| 56 | + ```xml |
| 57 | + <ItemGroup> |
| 58 | + <DotNetCliToolReference Include="SpecFlow.NetCore" Version="1.0.0-rc8" /> |
| 59 | + </ItemGroup> |
51 | 60 | ``` |
52 | 61 |
|
53 | 62 | 0. Add a `precompile` script: |
54 | 63 |
|
55 | | - ```json |
56 | | - "scripts": { |
57 | | - "precompile": [ "dotnet SpecFlow.NetCore" ] |
58 | | - } |
| 64 | + ```xml |
| 65 | + <Target Name="PrecompileScript" BeforeTargets="BeforeBuild"> |
| 66 | + <Exec Command="dotnet SpecFlow.NetCore" /> |
| 67 | + </Target> |
59 | 68 | ``` |
60 | 69 |
|
61 | 70 | 0. 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](https://github.com/stajs/SpecFlow.NetCore/issues/22). |
|
0 commit comments