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.