I have some tests that use the built in Microsoft.VisualStudio.TestTools.UnitTesting
, but can not get them to run.
I am using visual studio 2012 ultimate.
I have a solution of two projects; One has tests, using Microsoft.VisualStudio.TestTools.UnitTesting
, [TestClass]
before the class, [TestMethod]
before the test methods and reference Microsoft.VisualStudio.QualityTools.UnitTestFramework
(version 10.0.0.0, runtime version v2.0.50727). I have tried dot-net framework 3.5, 4 and 4.5 others give a re-targeting error.
I have tried to build the solution and project. Test explorer has the message `Build your solution to discover all available tests. Click "run all" to build, discover, and run all tests in your solution.
So the question is: How to I get visual studio to find the tests?
Have also tried to follow this: http://msdn.microsoft.com/en-US/library/ms379625%28v=VS.80%29.aspx but with no success: I get stuck in section getting started, when asked to right click and select create tests
. There is no create tests
.
I have this test(it compiles, but does not show up in test explorer):
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace tests {
[TestClass]
public class SimpleTest {
[TestMethod]
public void Test() {
Assert.AreEqual("a","a", "same");
}
}
}
I have now discovered (see deleted answer below) that it is because it is on a shared drive, but I don't as yet know how to get around it. (something about the security setting maybe).
None of the solutions here helped me. The tests wouldn't be discovered for one solution whereas another solution referencing the same projects worked fine. I finally solved this by deleting the solutionname.v12.suo file.
Tests do not like async methods. Eg:
After doing this:
It saw the test.
In my recent experience all of the above did not work. My test method
was not showing up but compiling fine. When I removed the
async
keyword the test the showed up in the Test Explorer. This is bacauseasync void
is a 'fire-and-forget' method. Make the methodasync Task
and you will get your test back!In addition, not having the Test project's configuration set to "Build" will also prevent tests from showing up. Configuration Manager > Check your Test to build.
Check that your test project is not set to Delay sign only in your project properties -> Signing. If it is, deselect it and do a clean rebuild.
A problem I've found is that tests don't get found in the Test Explorer (nothing shows up) if the solution is running off a network drive / network location / shared drive
You can fix this by adding an environment variable.
COMPLUS_LoadFromRemoteSources and set its value to 1
Adding my answer as this is the top result on Google for this.
I'm using Visual Studio 2015 and (unknowingly - I just ran
Install-Package NUnit
) installed the NUnit3 package NuGet to my test project. I already had the NUnit Test Adapter extension installed, and my tests were still not showing up.Installing the NUnit3 Test Adapter through Tools > Extensions and Updates fixed this for me.