« 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.

Blog powered by Typepad

February 2010

Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27