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).
I sometimes get the same symptoms.
What I did is:
1. Closed the Test Explorer window
2. Cleaned the solution
3. Rebuild the solution
4. Relaunched Test Explorer window from Test -> Windows -> Test Explorer.
And I got my test in Test Explorer window.
I know this is an older question but with Visual Studio 2015 I was having issues where my newly created test class was not being recognized. Tried everything. What ended up being the issue was that the class was not "included in the project". I only found this on restarting Visual Studio and noticing that my test class was not there. Upon showing hidden files, I saw it, as well as other classes I had written, were not included. Hope that helps
I ran into the same issue while trying to open the solution on a network share. No unit test would be detected by Test Explorer in this case. The solution turns out to be:
Control Panel -> Internet Options -> "Security" Tab -> Click "Intranet" and add the server IP address or host name holding the network share to the "Sites" list.
After doing this, I recompiled the solution and now tests appeared. This should be quite similar to the answer made by @BigT.
I hit the same problem while trying to open the solution on a network share in VS2013 Ultimate.
I corrected the problem by turning on
Control Panel -> Internet Options -> "Security" Tab -> Click "Local intranet", click on sites and make sure "Automatically detect intranet network" is ticked.
This is more to help people who end up here rather than answer the OP's question:
Try closing and re-opening visual studio, did the trick for me.
Hope this helps someone.
I was experiencing this issue many times when I try to build the solution in a different PC.
I am using NUnit and Specflow as well. By default My test project targets X86 But I have to change this to X64. Steps are 1. Test Menu -> Test Setting -Default Processor Architecture -> x64. 2. Clean Build 3. Build 4. If still tests didn't show up. 5. Go to Tools Extensions and Updates Then Install NUnit and Specflow libraries 6. Clean Build 7. Build
Then usually test will showed up in Test Editor.