My Visual Studio does discover my Xunit tests, but "run all" (ctrl+R, A) doesn't run them. I can however manually select these tests to run them.
Console output:
========== Discover test finished: 2 found (0:00:01,6982309) ==========
------ Run test started ------
========== Run test finished: 0 run (0:00:01,8070484) ==========
In addition to XUnit I've installed xunit.runner.console and xunit.runner.visualstudio. I tested to confirm this on a fresh project. On my actual project the same occurs. Ctrl+R, A does run all MSTests, though.
Why doesn't "run all" work with XUnit?
Run tests in Test Explorer If Test Explorer is not visible, choose Test on the Visual Studio menu, choose Windows, and then choose Test Explorer (or press Ctrl + E, T). As you run, write, and rerun your tests, the Test Explorer displays the results in a default grouping of Project, Namespace, and Class.
Ordering classes and cases Tests are executed in ascending order. If no Order attribute is specified default 0 is assigned. Multiple Order attributes can have same value.
xUnit.net does not require an attribute for a test class; it looks for all test methods in all public (exported) classes in the assembly. Set the Skip parameter on the [Fact] attribute to temporarily skip a test.
I had the same issue. When picked one by one the tests ran fine, but when selecting several or all tests only some of them were executed, leaving other tests with exclamation mark (not run) without displaying any exception message.
I have finally found the problem: one of the NuGet packages (in my case V8.Net) was causing an exception when loading x64 version in Any CPU configuration, which caused the test runner silently drop execution of some (seemingly random) tests.
I have found this in the Event Viewer:
Faulting application name: dotnet.exe, version: 2.2.27818.2, time stamp: 0x5d09400d
Faulting module name: V8_Net_Proxy_x64.dll, version: 1.0.0.1, time stamp: 0x5cc8b077
Exception code: 0x80000003
Fault offset: 0x0000000000f810ee
Faulting process id: 0x36a8
Faulting application start time: 0x01d5487db05f8083
Faulting application path: C:\Program Files\dotnet\dotnet.exe
Faulting module path: C:\[my project path].BaseTests\bin\Debug\netcoreapp2.2\V8_Net_Proxy_x64.dll
Report Id: 4a76ea19-6dac-4c83-b589-252722073405
Faulting package full name:
Faulting package-relative application ID:
Removing reference to the faulting dll solved the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With