Visual Studio 2013 doesn't discover unit tests
Visual Studio 2013 doesn't discover unit tests
I have a simple solution in visual studio 2013 that is composed by one web project, one library project and one unit test project. When I open the solution and try to run the unit tests they are not discover by visual studio. To run the tests I try to go to the menu and choose Test -> Run -> Run all tests or by opening the test explorer window. By those to methods visual studio doesn?t discover any tests in the solution.
Creating first a simple unit tests project and try to run the test, visual studio know discover the test and I can run it. Then, if I open my previous solution visual studio now discovers all the tests. I try to save my solution but closing it and reopening, without creating a unit test project first, the visual studio doesn?t find the tests again. This is a very strange behave that I don?t know why this is happening.
I used to working alone in this project that was using the source control git integrated with the visual studio team foundation. The problem of visual studio not discover the unit tests start when a new element came to the project and when I need to recreate the solution through the source control online. Before this, all tests always been discovered by visual studio.
For creation the unit tests I use the dll Microsoft.VisualStudio.QualityTools.UnitTestFramework. My version of visual studio is: Microsoft Visual Studio Express 2013 for Web Version 12.0.30723.00 Update 3. My version of .net framework is 4.5.50938.
All of my tests are like this:
[TestClass] public class Service1Test { [TestMethod] public void Test1() { Assert.IsTrue(True); } }
Answer by Noctis for Visual Studio 2013 doesn't discover unit tests
Make sure your test class is public
so it can be found. And if you're referencing another class, make sure of the same.
Also, sometimes if you have no Asserts or you're not decorating the test with a [TestMethod]
, a test might not be recognized.
2 more things: 1) Async unit tests act funny at best, and none at all at worst. Have a look at this article by Stephen Cleary and keep from there if it interests you.
2) If you use NUnit and you run into the same issues, keep in mind it's [TestCase]
for Nunit, instead of [TestMethod]
Having said the above, here's an article I've posted on the code project, with both MSTest
& NUnit
, in case you want to give it a spin and make sure you're not missing anything.
Answer by AndyG for Visual Studio 2013 doesn't discover unit tests
Some things I've noticed I have to do from time to time to get tests to show up properly.
If your solution is in a protected drive that you need administrator access to read/write, sometimes only a portion of the tests come up. Definitely run VS as administrator in that case.
If your solution is 64 bit, make sure that Test > Test Settings > Default Processor Architecture is set to x64. Sometimes it gets set to x86. Set it to x64, then rebuild.
Sometimes just restarting Visual Studio does the trick because the test explorer will start up again.
Don't forget to actually build the test project/solution
Answer by Jeferson for Visual Studio 2013 doesn't discover unit tests
I was facing the same problem and I've remembered, again (this situation happened before), that selecting "Mixed Platform" on the solutions platform menu works, as well as the other answers.
Answer by Farukh for Visual Studio 2013 doesn't discover unit tests
If you using NUnit, make sure to download NUnit Adapter first.
Go to Tools ? Extensions and Updates? ? Online ? search for "NUnit Test Adapter".
Answer by Mariusz Gorzoch for Visual Studio 2013 doesn't discover unit tests
I'm having this issue from time to time. What works for me is to shutdown Visual Studio and go to folder:
%LocalAppData%\Microsoft\VisualStudio\12.0\ComponentModelCache
and delete it content.
Once you open Visual Studio and load your project again Test Explorer should contain back your tests
Answer by Frank for Visual Studio 2013 doesn't discover unit tests
I had the same issue but none of the other solutions worked. Turns out that I was using the NUnit 3 framework with the 2 adapter.
If you're using NUnit 3, go to Extensions and Updates and install the NUnit3 Test Adapter.
Answer by zook2005 for Visual Studio 2013 doesn't discover unit tests
for me it was changing 'solution configurations' to Debug (instead of Release).
Answer by user5224229 for Visual Studio 2013 doesn't discover unit tests
go to the project menu > Configuration Manager check your test project platform matches the rest of the project and is check to build then rebuild.
Answer by kfn for Visual Studio 2013 doesn't discover unit tests
I came across the same issue. And investigated and found that the dll's were not build, and put in the right folder. as soon as I changed my configuration they appeared. - the Projects build options, what folder should be used? - the build menu entry build configuration, they should be checked.
that fixed it for me.
Answer by MartijnK for Visual Studio 2013 doesn't discover unit tests
For the Visual Studio 2013.5, clearing the \TestResults directory in the solution helped. Visual Studio corrupted the mdf file in which it stores the discovered tests, thus preventing the discovery of unit tests.
Answer by Adam Behrle for Visual Studio 2013 doesn't discover unit tests
For future googlers I had a rare scenario that caused this.
On my base test class I had a property named TestContext. This interfered with MSTest's reserved TestContext property causing all my tests to be hidden from VS/Resharper except one (which did not inherit from the base).
Answer by Alfons for Visual Studio 2013 doesn't discover unit tests
Try building all projects as MSIL (Any CPU) instead of x86/x64. Worked for me strangely
Answer by Roni for Visual Studio 2013 doesn't discover unit tests
Be sure your all projects are runing with the same configuration. Under your project's Properties => Debug => Platform in drop down list choose the appropriate platform (for me it was "Any CPU") as determined at your other projects.
Answer by Kevin Giszewski for Visual Studio 2013 doesn't discover unit tests
Just ran into this as well as I didn't see a similar case that was similar to mine.
In the .csproj
file of my test project, NUnit reference privacy was set to False
:
..\packages\NUnit.2.6.4\lib\nunit.framework.dll False
After I set
to True
it worked.
Answer by Seva for Visual Studio 2013 doesn't discover unit tests
My problem was because my unit test method wasn't void, and it was receiving parameters.
Answer by amalgamate for Visual Studio 2013 doesn't discover unit tests
- I know that the unit tests are not found if the solution is not built, so that is something to try (Build the solution), but that solution is like the help desk asking if your computer is plugged in...
- After a clean rebuild did not fix the problem for me, running a full batch build did fix it.
Answer by fox for Visual Studio 2013 doesn't discover unit tests
I'd managed to add mine as
public static void TestMethod1(){}
started working once I removed static....
Answer by HeatherD for Visual Studio 2013 doesn't discover unit tests
Had the same issue; tests suddenly stopped being discovered.
Nunit Test Adapter had become disabled somehow. Clicking enable in the extension manager fixed it for me.
Answer by Sandy_Vu for Visual Studio 2013 doesn't discover unit tests
You just need to install this package only:
NUnit TestAdapter
Answer by Mikal Madsen for Visual Studio 2013 doesn't discover unit tests
To get tests to show in the Test Explorer Window I had to install NUnit3 Test Adapter 3.0 which was not available in Package Manager.
Downloaded from https://visualstudiogallery.msdn.microsoft.com/0da0f6bd-9bb6-4ae3-87a8-537788622f2d
0 comments:
Post a Comment