Checking expected exception message when using MS Test

20 באוגוסט 2009

תגיות: , , , ,
3 תגובות

My blog has moved. You can view this post at the following address:

הוסף תגובה
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. שדות החובה מסומנים *

3 תגובות

  1. Yoav Michaeli20 באוגוסט 2009 ב 14:12

    you can check the error message with the attribute [ExpectedException(typeof(CriticalException), "An error occured")]

  2. dhelper20 באוגוסט 2009 ב 14:34

    Actually you can't!
    MSTest uses the string as a description and not as verification (like we're used from NUnit).

    See this post (as well as MS documentation):

  3. lior20 באוגוסט 2009 ב 17:30

    BTW NUnit also added the Assert.Throw syntax in the 2.5 version.
    Im guessing that like alwyas only MS is left behind (but im sure its a matter of time since we will see that as well).

    The only thing that I don't like about the assert.throw is that it forces you to mix the "act" part of the test with the "assert".