Wednesday, 14 May 2008

MS Test Re-Enabling Ignored Tests

In our current development environment we use MS Test for our unit testing and one thing that has been bugging me for a while is that if you remove the Ignore attribute from a test method, recompile and then try and run the test nothing happens and but you get a message in the status bar saying "No tests were run because no tests are loaded or the selected tests are disabled".

So I didn't really understand what that meant and usually ended closing Visual Studio, re-opening it and seeing if that fixed the problem, it didn't so I finally googled it and came across this MSDN article, in which it nicely explains that after adding the IgnoreAttribute to the unit test "The test is disabled. In the Properties window, the Test Enabled property is automatically set to False."

Now what should happen is when you remove the IgnoreAttribute the Test Enabled property is automatically set to True. However this does not seem to the case so after removing the IgnoreAttribute you need to either:

1. Open the Test View, select the ignored test, press F4 to display the properties window and set the Test Enabled property to True.

image

Or

2. Open the Test List Editor, selected the ignored test, right click and select "Enable" from the context menu.

image

I hope this helps anyone with future MS Test issues.

21 comments:

Unknown said...

Thanks man- helped me out. What an annoying message!

markell said...

Helped me too. Thanks.

Unknown said...

I was getting the "No tests were run because..." message too, but it was because I had accidently deleted all my tests (thinking I was only deleting the test runs.

The test code was still there but stubbornly refused to run any tests until I discovered that all the test methods were missing the [TestMethod()] attribute. Adding this back made all my tests reappear.

HTH

Robert

Anonymous said...

Thanks.
I was closing th eproject and deleting the .sou file.
This will be much better.

Unknown said...

Thanks a lot. This was a pain in the neck until I saw your post.

Anonymous said...

Thanks.

Unknown said...

Thank you!

Anonymous said...

Nice one!
one day MS will get helpful with their errors!

Anonymous said...

Thank you for this post! Spent most of my Friday afternoon trying to figure this out before finding this solution.

Anonymous said...

you made my day after hours of despair. re-adding [TestMethod()] to all the test methods is the key... thx for that!

Rahul Mehta said...

good and thanks...helped me

Rahul Mehta said...

thanks mate...it helps

Rahul Mehta said...

thanks mate

Rahul Mehta said...

thanks a lot

Rahul Mehta said...

thanks
Rahul Mehta

Rahul Mehta said...

thanks

Kevin Driedger said...

Restarting VS2010 seems to reset this problem as well.

Richard Allen said...

Yes to be fair restarting VS2010 would do it but maybe a little bit of overkill :-)

Anonymous said...

Thanks for this blog.

Restarting VS did not reset the test for me, and I simply couldn't figure out what the problem was.

sunil prasad said...

Thanks . It is very helpful for me .

Anonymous said...

Helped me too. Thanks