I'm porting a small library that I have on NuGet to .NET Core.
I've created .NET Standard 1.6 class libraries for the main project and the tests, and copied over the code. I changed the unit tests to use xUnit attributes and asserts rather than NUnit.
Other than that, I pretty much followed the instructions in the documentation, and thus I added the following NuGet packages:
- Microsoft.NET.Test.Sdk
- xunit
- xunit.runner.visualstudio
Alas, (1) Test Explorer does not find my unit tests, and (2) when I run dotnet test
, I get the following:
Starting test execution, please wait... Could not find testhost.dll for source '[...].Tests.dll'. Make sure test project has a nuget reference of package "microsoft.testplatform.testhost".
I have actually added the suggested Microsoft.TestPlatform.TestHost
NuGet package, but that hasn't changed anything.
So what is the problem here?
I'm using Visual Studio 2017. Not that I think it makes a difference.
Update: changing the test project from Class Library (.NET Standard)
to Class Library (.NET Core)
fixed the problem. I still don't get why this is supposed to make a difference.