ZeroSharp

Robert Anderson's ones and zeros

Sometimes You've Just Got to Deploy

| Comments

Sometimes the deadline has arrived and you still have some failing tests. After a discussion with the dev team, you decide to deploy anyway and fix the bugs for the next release. You need to get the build server to ignore the tests.

One way is just to mark the test with the [Ignore] attribute.

1
2
3
4
5
6
[Test]
[Ignore] // TODO: Fix this test before the next release!
public void Test()
{
    // Some failing test code...
}

After the weekend, everyone forgets about the ignored tests and they never get fixed.

Instead, I like to do this.

1
2
3
4
5
6
7
[Test]
public void Test()
{
    if (DateTime.Now < new DateTime(2016, 10, 17))
        Assert.Ignore("Temporarily ignored until October 17.");
    // Some failing test code...
}

This is a fairly rare occurrence for my team, so the above approach is sufficient and works with all test frameworks. But if you want to go further Richard Slater shows how to create an NUnit attribute.

Comments