UPDATE: Adding a 2019; the discovery/runner integration mechanism is same as per 2017 & 2015, so the key things that can go wrong are the same.
I've read Why is the xUnit runner not finding my tests, which covers reasons xUnit would never be able to find your tests but my problem is different - I'm confident there's nothing subtle going on with my tests; (they have worked in other environments, this seems to be just my machine) - the Visual Studio Test Runner in Visual Studio 2015 [Community Edition] is simply not showing any of my tests. I'm not doing anything remotely exciting; the tests target xUnit.net v2 on the Desktop.
I've looked in the Output window and am not seeing anything in at all under Test in the Show output from tabs.
After spending 2 days... none of the above worked for me. The only "solution" was: Go to project properties -> Build Tab. Then click Advanced button on the right bottom corner of the pane. Change "Debug Info:" to "full" and click OK.
Here are the screen shots:
Make sure that your test class is public.
The reason in my case was the target build was not the same between project debugger and test runner. To unify those elements:
After they are identical, rebuild your solution then test methods will appear for you.
Install
xunit.runner.visualstudio
package for the test projectI can provide a solution for an edge case I ran into a few days ago. It's not gonna be the solution that fits all of the scenarios described above, however, for the edge case I had it fixed it.
I had the same issue with most recent VS 2017 (version 15.5.7) and XUnit 2.3.1. The xunit.runner.visualstudio package was installed, however, the tests didn't show up in VisualStudio's built-in test explorer.
I was working on a legacy project that was targeting .NET framework 4.5. However, beginning with version 2.2. XUnit does not support .NET frameworks lower thant 4.5.2 (see Release Notes - XUnit 2.2: February 19, 2017
Changing the test project's target framework to a version >= 4.5.2 worked for me. You don't have to change the project's version that you're testing, it's just about the test project itself.
I had the same issue with Visual Studio 2019. Just Installed the following NuGet packages and the issue was solved.
1). xUnit
2). xunit.runner.visualstudio
3). Microsoft.TestPlatform.TestHost
4). Microsoft.NET.Test.Sdk