Tuesday, May 26, 2009

Should I ignore NUnit 2.5?

I use built-in test runner in ReSharper to run NUnit tests. But this code fragment is passed with NUnit 2.5, but not with NUnit 2.4.8. Try to find, sadly, it is problem of licensing.

public void DivideANumberByZeroShouldThrowException()
// do nothing

I can use NUnit test runner, but I prefer to use ReSharper built-in test runner, which provides visualization to see the result. Should I ignore NUnit 2.5?

Update: After a while, I have the answer is "No". But to use ReSharper to run tests with expected exceptions, I need to change the way how to write test code. There are 2 ways to make the test runs well:

Assert.That(delegate { clz.Divide(3, 0); }, Throws.InstanceOf<ArgumentException>());


Assert.Throws<ArgumentException>(delegate { clz.Divide(3, 0); });

I prefer the first way.

Update: Good to know that now ReSharper's NUnit runner can run tests with ExpectedException attribute, v4.5.1 (http://www.jetbrains.net/devnet/thread/281286?tstart=0)

No comments: