NUnit 2.2 Timed Tests...
Well I finally got around to working on some more NUnit enhancements. I have finished creating an extension for a timed test with resolution in milliseconds. I had to make several modification to NUnit.Core.TemplateTestCase to ensure code reuse.
A sample of a the new extension is shown below:
using NUnit.Extensions;
namespace NUnit.Extensions.Tests {
[TestFixture]
public class TimedTestFixture {
public TimedTestFixture() {}
[TimedTest(5000)]
public void NapOk() {
Thread.Sleep(2500);
}
[ExpectedException(typeof(TestTimeoutException))]
[TimedTest(200)]
public void NapTooLong1() {
Thread.Sleep(500);
}
[TimedTest(2000)]
[ExpectedException(typeof(TestTimeoutException))]
public void NapTooLong2() {
Thread.Sleep(500000);
}
}
}
If the TimedTest attrribute is defined with a negative timeout, the test is run as if it were declared as a standard Test attribute.
Get the source packaged along with my ObjectGraphAssert extension here.