Running xunit tests included in the .NET Standard 1.6 library

I just created the netstandard library in Visual Studio 2017 and added links to xunitand xunit.runner.visualstudio, but Test Test Test and Resaarper 2017 EAP 3 do not recognize any tests. I saw: Unit testing the .NET Standard 1.6 library , but project.json was gone, and csproj was back in place.

What do I need to do to be able to run unit tests included in the 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);
        }
    }
}

enter image description here

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>

. TargetFramework netcoreapp1.1, VS . netstandard1.6 Test Explorer . netcore. .NET.

+5
4

dotnet new xunit, .

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />

IDE. ,

dotnet test -l "trx"

netstandard1.5; net452, net452, netstandard1.5.

+1

, , ( .net) . Infact many tutorials, (, : http://dotnetcoretutorials.com/2017/01/30/running-unit-tests-dotnet-test/) CONSOLE, , .

, , , , .net? , , .net, . , , .

+1

, , - xunit, Visual Studio Xamarin.iOS/Droid. netstandard Unit test, .NET Core 2.0, Xamarin. * ( ) Shared netstandard. .

:

  • Project.Tests.Droid( Droid UI)
  • Project.Tests.iOS( iOS)
  • Project.Tests.Unit( VS Unit test)
  • Project.Tests( )

Project.Tests.

+1

This is difficult, but doable if you are linking to another answer, as well as to the sample project below,

https://github.com/lextm/sharpsnmplib/blob/master/Tests/Tests.NetStandard.csproj

Of course, some of the NuGet packages used in the sample are already updated to stable.

The following are criticisms: A <PackageReference Include="Microsoft.NET.Test.Sdk"> <Version>15.0.0-preview-20170125-04</Version> </PackageReference> <PackageReference Include="xunit"> <Version>2.2.0-beta5-build3474</Version> </PackageReference> <PackageReference Include="xunit.runner.visualstudio"> <Version>2.2.0-beta5-build1225</Version> </PackageReference> project containing unit test events should be a console application designed for .NET Core.

0
source

All Articles