Visual Studio 2017 + .Net Core 2 Tests not executable

I had exactly the same problem after moving from NUnit to XUnit on a large solution.

I tried creating a new project that contained just a single dummy test. This also exhibited the problem, meaning it was environmental.

I eventually discovered Git had placed double quotes around its entry in the PATH environment variable, like this:

...;"C:\Program Files (x86)\Git\bin";...

Unfortunately, my path was very long (3600 chars), so the Windows GUI would not let me change it as it was more then 2047 chars.

I was able to correct it by changing the Path stored in the Windows Registry at Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment

I was able to reproduce the behaviour at will by re-adding the quotes to the Path environment variable.

I think there was a bug with an older version of Git I had installed (long ago) which added the quoted locate to the path environment variable, and newer updates never changed it. I suspect the NUnit test runner was tolerant of the quotes, while the XUnit test runner is not.

I hope my experience helps with your issue.


Just in case someone still has the same issue of "0 Tests Found -- Invalid Character in path". I was experiencing it but I was able to solve it, however, it took me two days to find the solution. The solution is very simple but at the time it was not clear to the surface. Solution: (Windows - PCs)

  • Open This PC -> Properties -> Advanced system settings -> Environment Variable -> User variables
  • Scroll to the "path" and click Edit and then click "Edit text..."
  • check the whole text and remove any double quotes, <> if they are available and click OK.
  • Do the same with System variables path.
  • Head back to Visual Studio, build your solution and Run All tests.

After these steps, the tests should be found this time.