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.

4 comments:

Nicholas said...

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

markell said...

Helped me too. Thanks.

revcom 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.