Why does visual studio 2012 not find my tests?
I had same symptoms, but under different circumstances.
I had to add one additional step to Peter Lamberg's solution — Clean your solution/project.
My unittest project targets x64. When I created the project it was originally targeting x86.
After switching to x64 all my unit tests disappeared.
I had to go to the Test Menu -> Test Setting -Default Processor Architecture -> x64.
They still didn't show up.
Did a build.
Still didn't show up.
Finally did a Clean
Then they showed up.
I find Clean Solution and Clean to be quite useful at getting the solutions to play ball when setting have changed. Sometimes I have to go to the extreme and delete the obj
and bin
directories and do a rebuild.
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");
}
}
}
This sometimes works.
Check that the processor architecture under Test menu matches the one you use to build the solution.
Test -> Test Settings -> Default Processor Architecture -> x86 / x64
As mentioned in other posts, make sure you have the Test Explorer window open. Test -> Windows -> Test Explorer
Then rebuilding the project with the tests should make the tests appear in Test Explorer.
Edit: As Ourjamie pointed out below, doing a clean build may also help. In addition to that, here is one more thing I encountered:
The "Build" checkbox was unticked in Configuration Manager for a new test project I had created under the solution.
Go to Build -> Configuration Manager. Make sure your test project has build checkbox checked for all solution configurations and solution platforms.
I have Visual Studio 2012 and i couldn't see the Tests in Test Explorer,
So I installed the following: NUnit Test Adapter
That fixed the issue for me !