When writing configuration tests, that is tests against environmental configuration, it is sometimes a requirement to ignore a test until a specific point in time when some external resource becomes available, for example the deployment of a configuration setting to a specific environment on a specific date. NUnit’s Ignore attribute does not support any parameters, nor does NUnit provide a conditional ignore attribute.
It would of course be possible to place a conditional clause at the top of each of your tests and issue an Assert.Ignore() at the appropriate point, as this will case NUnit to stop executing and report the test status as Ignore:
This gets messy very quickly however as it adds a few lines of code to the top of each of the tests you want to control. In addition it makes it harder to read the test when you return to it at a later time.
ABSTRACTING AWAY THE CONDITIONAL IGNORE
NUnit provides an interface called ITestAction which allows a block of code to be executed before and after each test
This gives us the capability to conditionally ignore a test based upon a date:
The result, if you happen to be running ReSharper in Visual Studio 2013: