Have you ever had a unit test that you didn’t want executed as part of your team’s test runs? For example, if it requires external data but you haven’t yet set up the test database. Or you’ve been using a unit test as a workbench for developing some code that you’re interacting with in the debugger and don’t really want it to be run by others.
Up until recently, I would either comment out the [TestMethod] attribute or comment out the entire test method’s code.
But there’s a better way, as a colleague of mine recently advised – the [Ignore] attribute.
Decorating your test method with this attribute will prevent it from being run.
The nice thing about this is your test code will still be compiled and refactored with the rest of your codebase.
When you do want the test to run while you’re working with it, just uncomment the [Ignore] attribute. Then when you’re ready to check in your test, comment it back and you’re all set to go.
Hope this helps.