Could not find testhost
A while back I wrote an article on this subject where you have NUnit tests not running in Visual Studio and how to fix it. In this blogpost I will share the same soluition expect with xUnit since it involves some other packages and error messages it might not be clear that it is a related issue.
Background:
Let's say we have a .NET Class Library project and we've installed the following packages:
PM > Install-Package xunit
PM > Install-Package xunit.runner.console
PM > Install-Package xunit.runner.visualstudio
Next we create an example test and this pops up in the Visual Studio Test Explorer as expected.
The issue:
When we run our test we get the following results:
Test run finished: 0 Tests (0 passed, 0 Failed, 0 Skipped)
And if you look in the Tests output we see the following message:
"Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost"
The solution:
What you need to do is install an additional package:
PM > Install-Package Microsoft.NET.Test.Sdk
And you're all good! ✅ More info can be found in the related article.
Cheers friends! ❤️