visualstudio.xunit
visualstudio.xunit copied to clipboard
Live Unit Testing broken with VS 2017
Running Visual Studio Enterprise 2017 Version 15.9.6 VisualStudio.15.Release/15.9.6+28307.344 Microsoft .NET Framework Version 4.7.03062
NuGet packages: xunit version 2.4.0 xunit.runner.visualstudio version 2.4.1
In a .NET Core 2.2 application and .NET Core 2.2 test project, enabling Live Unit Testing in Visual Studio results in the following error, in the Live Unit Testing output window:
[09:10:06.202 Info] [TestRunner 1] [xUnit.net 00:00:00.26] Tests: Exception filtering tests: No tests matched the filter because it contains one or more properties that are not valid (TestCategory, Category). Specify filter expression containing valid properties (DisplayName, FullyQualifiedName) and try again.
[09:10:06.232 Info] [TestRunner 1] No test is available in C:\Git\MySolution\lut\0\t\Tests\Debug\netcoreapp2.2\Tests.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.`
Running the tests using the regular, non-live Visual Studio test runner works fine and the tests complete successfully.
Please provide a repro project. Thanks!
I had the same problem in my solution - UTs ran fine when explicitly started, but no Live UTs were run with the "No tests matched the filter" message until I added Microsoft.Net.Tests.Sdk nuget. That brought all but one project to live (pun intended).
The last project was fixed by removing a lingering section from a previous structure: The csproj file contained the below, even though there was no wwwroot folder anymore.
<ItemGroup>
<Compile Remove="wwwroot\**" />
<Content Remove="wwwroot\**" />
<EmbeddedResource Remove="wwwroot\**" />
<None Remove="wwwroot\**" />
</ItemGroup>```
It seems to me, that Microsoft.Net.Tests.Sdk
package presence is a (undocumented) requirement for Live Unit testing to work.
Attached repro: BrokenLiveUnitTesting.zip. When you uncomment the package reference in the test project, it works.
@josefblaha The documentation page shows the package as a requirement:
The documentation is a few months old, so it doesn't show the latest package version, but that's to be expected (docs going out of date shortly after they're written). It's considered to be common practice to always use the latest package versions.
Well, I missed that :) My premise was that since VS test runner worked well without the package, it was a requirement of Live Unit testing feature only. Now it's clear, that the package is a requirement of any test project.
The package is included in the latest VS test project templates as well, so new projects shouldn't have this problem.
It comes as a dependency from xunit.runner.visualstudio
, but the dependent version it pulls in is too old for live unit testing. So... it is necessary to make VS Test Explorer and/or dotnet test
work, but you're getting it implicitly instead of explicitly.
https://www.nuget.org/packages/xunit.runner.visualstudio