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 ultimat
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.
I had the same problem.. In my case it was caused by a private property TestContext
.
Changing it to the following helped:
public TestContext TestContext
{
get;
set;
}
After cleaning and building the solution (as described in @Ourjamie 's answer), the test methods in the affected test class were available in the Test Explorer.
Check referenced assemblies for any assemblies that may have "Copy Local" set to "False".
If your test project builds to it's own folder (bin/Debug for example) and the project depends on another assembly and one of those assemblies in the References list is marked Copy Local = "False", the assembly cannot load due to missing dependencies and your tests will not load after a build.
Please add the keyword public to your class definition. Your test class is currently not visible outside its own assembly.
namespace tests {
[TestClass]
public class SimpleTest {
[TestMethod]
public void Test() {
Assert.AreEqual("a","a", "same");
}
}
}
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.
In my recent experience all of the above did not work. My test method
public async void ListCaseReplace() { ... }
was not showing up but compiling fine. When I removed the async
keyword the test the showed up in the Test Explorer. This is bacause async void
is a 'fire-and-forget' method. Make the method async 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.