I just created a netstandard library in Visual Studio 2017 and added references to xunit
and xunit.runner.visualstudio
, but the VS Test Explorer and Resharper 2017 EAP 3 are not recognizing any tests. I've seen: Unit testing a .NET Standard 1.6 library but project.json is gone and csproj is back in place.
What do I have to do, to be able to run the unit tests included in a netstandard library?
Library.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.6</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
</Project>
Test.cs
namespace ClassLibrary2
{
public class Class1
{
[Fact]
public void RescharperShouldRunTest()
{
Assert.True(true);
}
}
}
Edit
Thanks to the answers I made some progress.
Adding
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<!-- ... and ... -->
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
did have no impact. Only if I change the TargetFramework
to netcoreapp1.1
VS discovered the test and could run them. With netstandard1.6
the Test Explorer remains empty. But I don't want a netcore app. I want a .NET standard library.