views:

499

answers:

3

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 ?

+2  A: 

Check out http://blogs.msdn.com/vstsqualitytools/archive/2010/03/03/run-tests-in-current-context-after-upgrading-from-visual-studio-2010-beta2.aspx

arch stanton
Thanks for your answer. Unfortunately, this is happening in a new project, created in Visual Studio 2010 RTM. I did try saving the .testsettings file as suggested in your link, but it didn't help.
driis
+3  A: 

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
+8  A: 

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.

Options dialog

driis
Thank you! This is has been so frustrating since upgrading. Why in the world is discovery disabled by default?
sgwill