not able to run tests after updating xunit.runner.visualstudio to version 2.4.2
version 2.4.1 has been working fine. After updating to 2.4.2, dotnet test is giving the following error:
`Unable to find /Users/user/dev/project/Commontests/bin/Debug/netcoreapp3.1/testhost.dll. Please publish your test project and retry.
Test Run Aborted.`
Do you have a repro project?
If your project compiles fine but fails to execute the tests, I would suspect a problem with Microsoft.NET.Test.Sdk, especially when it complains about a missing testhost.dll. Do you reference the last version (v16.6.1)?
@chtoucas Adding Microsoft.NET.Test.Sdk brings it back working again. But I did not reference this package at all before updating to 2.4.2 and it was working fine. Is this a new requirement?
@buzhidao77 I honestly don't know, but it's true that with 2.4.1 "dotnet test" worked fine without it.
Exact same issue here. Is the "official" fix to install Microsoft.NET.Test.Sdk ? This was not required for 2.4.1
Seeing this as well - worse, however, is while adding the Test.Sdk package fixes things on my dev box, it does not fix things on my Jenkins agent. I can't for the life of me figure out how to fix things on that build agent...
Do you have a repro project?
Here is a repro project @clairernovotny.
After building, the contents of Output -> Tests essentially says
TestPlatformException:
Unable to find `{path to repo}\Tests\bin\Debug\netcoreapp3.1\testhost.dll`.
Please publish your test project and retry.
Here is my full output.
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Unable to find C:\Users\twilliams\Downloads\MWE\Temp\Tests\bin\Debug\netcoreapp3.1\testhost.dll. Please publish your test project and retry.
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostPath(String runtimeConfigDevPath, String depsFilePath, String sourceDirectory)
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)
Closing as the latest test sdk reference is the fix.
@clairernovotny, I am confused. Can you help clarify something for me?
Is Microsoft.NET.Test.Sdk necessary for xunit.runner.visualstudio to work correctly or is it possible to use xunit.runner.visualstudio without Microsoft.NET.Test.Sdk?
Seems like version 2.4.1 has a dependency to Microsoft.NET.Test.Sdk (>= 15.0.0), which has been removed in version 2.4.2 and 2.4.3.
Reference: https://www.nuget.org/packages/xunit.runner.visualstudio/2.4.1
@clairernovotny, why was the dependency removed, when it seems like you need the Test.Sdk for xunit.runner.visualstudio to work?
The test SDK should be brought in directly by your project, not the xUnit adapter.
Thanks for the response @clairernovotny. Unfortunately, I am still confused. Could you elborate?
My understanding of your comment is that I should add a direct dependency from my test project to Microsoft.NET.Test.Sdk, but I should not add a direct dependency to xunit.runner.visualstudio. Am I understanding your comment correctly?
I want to see my tests in Visual Studio's Test Explorer. How can I get them to appear there without directly depending on xunit.runner.visualstudio?
Also, why do you say that I should add a direct dependency from my test project to Microsoft.NET.Test.Sdk? Does xunit or xunit.runner.visualstudio require this NuGet package in order to work correctly?
You need both references.
Thanks @clairernovotny. Your answers continue to be a bit terse from my perspective. Like the others, I will unpack it by explaining how I understand it to make sure we are communicating effectively.
My understanding of...
You need both references.
...is that you are answering my question in https://github.com/xunit/visualstudio.xunit/issues/219#issuecomment-668334362...
Is
Microsoft.NET.Test.Sdknecessary forxunit.runner.visualstudioto work correctly or is it possible to usexunit.runner.visualstudiowithoutMicrosoft.NET.Test.Sdk?
...by saying that Microsoft.NET.Test.Sdk is necessary for xunit.runner.visualstudio to work correctly.
If Microsoft.NET.Test.Sdk is necessary for xunit.runner.visualstudio to work correctly, then why doesn't xunit.runner.visualstudio have a NuGet package dependency on Microsoft.NET.Test.Sdk?
As pointed out by @Tino92 and others, 2.4.1 brought the dependency with xunit install, now the user have to do it manually. Seems like a strange decision to remove it from 2.4.2/3. At a minimum I would expect this to be documented somewhere, which I don't believe it currently is, unless I overlooked it.
From a user point of view, I was using 2.4.1 without any issues, and after upgrading to 2.4.2 in the same projects running my tests stopped working. Seems like a breaking change to me.
from 2.4.1 to 2.4.2 is supposed to be a non-breaking change, right?
It is supposed to be a non-breaking change if the version numbers are to satisfy semantic versioning. Maybe version numbers for xunit.runner.visualstudio do not follow semantic versioning.
None of xUnit.net today uses semantic versioning, as our version numbers pre-date the existence of semantic versioning.
Are you saying that it is impossible to start using semantic versioning for versions of software released before the existence of semantic version?
@bradwilson, in https://github.com/xunit/xunit/issues/1986#issuecomment-539090954, you said that you don't want to introduce breaking changes (without mention on how the version number changes).
Do you feel the same way about the change discussed in this issue?
(In case it is unclear, the change being discussed in this issue was breaking for many people including myself.)