« xUnit.net 1.0 Released Today | Main | Lessons Learned in Programmer Testing »

June 25, 2008


Feed You can follow this conversation by subscribing to the comment feed for this post.

Keith J. Farmer

My biggest complaint about ExpectedException was that you were never able to validate that, amoung all exceptions of a particular type, that you were able to verify the correct message in a localizable manner.

So we, too, created an expected exception method, that took the expected exception method as well. We also went a little further, and took a params Action[] so we would assert for each test in a sequence within a particular method.


You could put details in the expected exception to isolate a particular exception.

[ExpectedException( typeof( ArgumentException ), ExpectedMessage="Deposit amount cannot be zero" )]


[ExpectedException( "System.ArgumentException", ExpectedMessage="Deposit amount cannot be zero" )]

Hence this code would fail because it had the wrong message. You would then change the test to fix the problem with the setup of checking account.

The comments to this entry are closed.