can anyone help me get VS2017 to work with .NET Core test projects?
I tried creating both MSTest and xUnit unit test projects for .NET Core from the VS 2017 templates. Neither of them works in the test explorer (not discovered), however running dotnet test
from the project folder works fine.
Steps to reproduce:
Unit Test Project (.NET Core)
or xUnit Test Project (.NET Core)
templateRun All
At this point the Output window should tell you that 0 test were discovered
.csproj
file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
</Project>
If I tried to create a MSTest unit test project from the template that targets .NET Framework (full, not .NET Core), it worked.
Any ideas?
Run Visual Studio 2017 and Select File > New Project. On the left menu select Visual C# > . NET Core. On the list of application templates pick ASP.NET Core Web Application.
Run tests in Test Explorer If Test Explorer is not visible, choose Test on the Visual Studio menu, choose Windows, and then choose Test Explorer (or press Ctrl + E, T). As you run, write, and rerun your tests, the Test Explorer displays the results in a default grouping of Project, Namespace, and Class.
To enable Live Unit Testing, select Test > Live Unit Testing > Start from the top-level Visual Studio menu.
In the end, the problem was solved by changing my system PATH
env. variable from C:\Program Files\dotnet\
to C:\Progra~1\dotnet\
, as answered in Can't get XUnit tests working with Visual Studio 2017 RC
Thanks to Alexey for suggesting it in the comments :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With