Problem
Some of my tests make advantage of Microsoft’s built-in features. VisualStudio. TestTools. I’ve tried UnitTesting but haven’t been able to get them to run.
Visual Studio 2012 Ultimate is what I’m using.
I have a solution that consists of two projects: one contains testing and the other uses Microsoft. VisualStudio.TestTools. [TestClass] comes before the class, [TestMethod] comes before the test methods, and [Reference] comes before the reference. Microsoft.VisualStudio.QualityTools.UnitTestFramework is a Microsoft.VisualStudio.QualityTools.UnitTestFramework class (version 10.0.0.0, runtime version v2.0.50727). I’ve tried.NET Framework 3.5, 4, and 4.5, but all of them result in a re-targeting issue.
I attempted to construct the solution and project. The message ‘Build your solution to discover all available tests’ appears in the Test Explorer. To create, discover, and execute all tests in your solution, click “run all.”
So here’s the question: how can I get Visual Studio to look for the tests?
I’ve also attempted to follow this link: http://msdn.microsoft.com/en-US/library/ms379625% 28v=VS.80% 29.aspx however, without success: When I’m asked to right-click and select Create Tests under the section Getting Started, I get stuck. There isn’t a way to make tests.
I have the following test (which compiles but does not appear in the test explorer):
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace tests {
[TestClass]
public class SimpleTest {
[TestMethod]
public void Test() {
Assert.AreEqual("a","a", "same");
}
}
}
I’ve now realized (see deleted response below) that it’s because it’s on a shared disk, but I’m not sure how to get around it. (Perhaps something to do with the security settings).
Asked by ctrl-alt-delor
Solution #1
I experienced the same symptoms as you did, although in a different setting.
To Peter Lamberg’s solution, I had to add one more step: Clean your solution/project.
The target platform for my unittest project is x64. It was originally intended for x86 when I started the project.
All of my unit tests vanished after I switched to x64.
I had to go to the Test Menu -> Test Setting -Default Processor Architecture -> x64 to solve the problem.
They haven’t arrived yet.
Did a build.
He has yet to appear.
Eventually, I completed a Clean
Then they appeared.
When the settings have changed, I find Clean Solution and Clean to be very helpful in getting the solutions to cooperate. I occasionally have to go to extremes and erase the obj and bin directories before rebuilding.
Answered by Ourjamie
Solution #2
Please include the keyword public in the definition of your class. Outside of its own assembly, your test class is currently invisible.
namespace tests {
[TestClass]
public class SimpleTest {
[TestMethod]
public void Test() {
Assert.AreEqual("a","a", "same");
}
}
}
Answered by Joseph King
Solution #3
This sometimes works.
Verify that the processor architecture listed in the Test menu corresponds to the one you used to create the solution.
Default Processor Architecture -> x86 / x64 -> Test -> Test Settings -> Default Processor Architecture -> x86 / x64
Make sure the Test Explorer window is open, as indicated in previous blogs. -> Windows -> Explorer -> Test
The tests should then appear in Test Explorer after rebuilding the project with the tests.
Edit: As Ourjamie mentioned below, a clean build may also be beneficial. Aside from that, here’s something else I came across:
In Configuration Manager, I had unticked the “Build” button for a new test project I had established beneath the solution.
To access the Configuration Manager, go to Build -> Configuration Manager. Check the build checkbox for all solution configurations and solution platforms in your test project.
Answered by Peter Lamberg
Solution #4
I’m using Visual Studio 2012 and I’m having trouble seeing the tests in Test Explorer.
So here’s what I did: Adapter for NUnit Tests
For me, that resolved the problem!
Answered by dnnyz
Solution #5
All of the above did not work in my recent experience. My way of testing
public async void ListCaseReplace() { ... }
Although it wasn’t displaying up, it was compiling correctly. The test appeared in the Test Explorer after I removed the async keyword. Because async void is a ‘fire-and-forget’ method, this is the case. You’ll get your test back if you make the function async Task.
Furthermore, failing to set the Test project’s configuration to “Build” will prevent tests from appearing. Check your Test to build in Configuration Manager.
Answered by MoonKnight
Post is based on https://stackoverflow.com/questions/13533259/why-does-visual-studio-2012-not-find-my-tests