visualstudio.xunit
visualstudio.xunit copied to clipboard
Unable to find testhost if xunit.runner.visualstudio is "Transitive" 😢
G'day 👋🏻
Problem: If the runner is imported/added to the project via transitive dependencies then the VS Test Explorer fails to 'see' it and dies:
Log level is set to Informational (Default).
Connected to test environment '< Local Windows Environment >'
Test data store opened in 0.017 sec.
Loaded 0 test records from the solution cache in 0.235 sec.
========== Starting test discovery ==========
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.5+1caef2f33e (64-bit .NET 6.0.7)
[xUnit.net 00:00:03.89] Discovering: Foo.UnitTests
[xUnit.net 00:00:04.13] Discovered: Foo.UnitTests
========== Test discovery aborted: 674 Tests found in 5 sec ==========
Why would we do this?
We have a nuget package that contains the following packages:
- xUnit
- xUnit.runner.visualstudio
- coverlet
- shouldly
- moq
So now when we create a test project, we just add that one nuget package, which then 'imports' all of those other packages via transitive.
(Side note: we also wanted to include the the Microsoft.NET.Test.Sdk
as a transient package ... which was confirmed as a bug and is scheduled to be fixed)