44

I am writing some unit tests in Visual Studio 2010. I can run all tests by using "Run all Tests in Current Context".

However, if I write a new unit test, it does not get picked up by the environment - in other words, I am not able to find it in Test List Editor, by running all tests, or anywhere else. If I unload the project and then reload it; the new test is available to run.

When I am adding a unit test, I simply add a new method to an already existing TestClass and decorating it with [TestMethod] attribute - nothing fancy.

What might be causing this behaviour, and how do I make it work ?

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
driis
  • 161,458
  • 45
  • 265
  • 341
  • What are the steps you are doing that is causing a problem? There are several ways to run tests, so it is hard to come up with a good answer. – James Black Apr 25 '10 at 14:13
  • @James, I use either "Run tests in current context" or "Run all tests in solution" from the toolbar. Normal behavior of these is to include any new tests that I have added. – driis Apr 26 '10 at 12:34

4 Answers4

73

I finally figured out the problem. In Options under Test Tools -> Test Project, there is an option "Disable background discovery of test methods". It was turned on - I do not know how that happened, but removing the checkmark and restarting Visual Studio solved the problem.

driis
  • 161,458
  • 45
  • 265
  • 341
3

I've had this problem as well when building in debug mode. When I switched it to build in release mode that fixed it for me.

amurra
  • 15,221
  • 4
  • 70
  • 87
2

I had a similar problem in Visual Studio 2012, however none of the solutions worked. I am developing a 64 bit application and the solution was to choose:-

Test -> Test Settings -> Default Processor Architecture -> X64
HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
Cookie
  • 121
  • 6
0

I've had this issue and option 2 below fixed it for me.

  1. Remove any app.config file (not sure why, but one of the MS forums has a few of these posts with this solution) and

  2. Ensure that within the configuration properties of the solution the project is set to build!!

Dave
  • 8,163
  • 11
  • 67
  • 103