05 Mar 2014, 00:24

How to fix Visual Studio 2013 not seeing unit tests

I recently ran in to this issue where Visual Studio 2013 didn’t see any of my MSTest unit tests, but only one machine. The repository for the code was identically cloned on three different machines and only the one was exhibiting the problem. I spent at least five days trying to solve this problem, trolling through StackOverflow, Google, Bing, and various forums, all to no available.

I finally found the solution.

Symptoms

  • If I were to right-click on the solution or project level and tell Resharper to run all the tests in the solution or the project, I would get an error “No tests found in file” or “No tests found in solution.”

  • If I opened a code file that contained a test class and test methods, the Resharper test runner would sometimes load the tests, but if I tried to run them they wouldn’t actually run, and Resharper would report them all as Inconclusive.

  • If I were to tell Visual Studio to run all tests, the progress bar would complete, but the list of tests in the test runner would still be empty.

Solution

As it turns out, there was one difference with this single environment vs. the other two; the location of the code. In this one environment, the source code was located on a mapped network share. That was preventing Visual Studio from being able to work with the code properly. You may at some point have gotten a dialog from Visual Studio when opening the project or solution telling you that the code is an untrusted location. That’s the root of the issue. Visual Studio will still open the solution, compile the code, and run it, but the test runner won’t be able to do anything with it. The solution is simple, but stupid.

Open the Windows control panel, and open the Internet Options. From there, select the Security tab. Select the Trusted Sites group, and click the Site button. In the dialog that opens, add the IP address of the machine that the network share lives on. Save your back through the various dialogs, restart Visual Studio, clean and rebuild your project, and now the Visual Studio test runner or Resharper should have no problem seeing your tests.

Special Thanks to Microsoft

You know, for silently failing when not being able to work with the files that you asked it to work with.