Gotchas: MSTest’s [Ignore] attribute
Friday, October 5, 2007 – 8:45 AMHow would you expect of the following to behave?
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace DependencyItemTests
{
[TestClass]
public class IgnoreAttributeFixture
{
[TestMethod]
[DependencyItemTests.Ignore]
public void IgnoreAttributeCheckingNotFullyQualified()
{
}
}
public class IgnoreAttribute : Attribute
{
}
}
I’d expect the IgnoreAttributeCheckingNotFullyQualified test to run just fine. But it doesn’t, it’s ignored (grayed out in the test view). This is because the MSTest framework isn’t using fully qualified types when it checks for the Ignore attribute.
Why did this come up? Well I was trying to port a whole load of tests from NUnit to MSTest. The approach I took was the modify my build to run all the tests using both NUnit and then MSTest. I then added an MSTest Ignore
attribute to all of them. The plan was to migrate them across and as I did so change the Ignore
from MSTest to NUnit. So as tests were migrated I’d move them from being ignored by MSTest to being ignored by NUnit.
Needless to say this strategy doesn’t work because MSTest will treat the tests as ignored in both places. Worth knowing if you were considering something similar.
Sorry, comments for this entry are closed at this time.