Timeline for Should I use try catch in my test methods?
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 7, 2011 at 15:33 | comment | added | mcottle | @Jwenting Read the second paragraph - Unit testing frameworks catch the exceptions and allow tests to pass if certain exceptions are raised and fail if they are not | |
| Sep 7, 2011 at 11:04 | comment | added | jwenting | You DO want to catch exceptions, as you DO want to test the situations in which exceptions happen (especially your own exceptions). If you write code that's designed to fail with an exception under certain conditions, those conditions should be a part of your test suite, and thus should be tested. Under those tests, those exceptions should be caught and analysed. | |
| Aug 18, 2011 at 9:05 | comment | added | deadalnix | Sometimetime, you want to check if an Exception is thrown, because good testing don't test only cases were things works, but also cases when they fail. | |
| Aug 18, 2011 at 8:43 | comment | added | Vikas | I think advanced testing framework can handle exception very well, even I find that in Visual studio we can test against exceptions like you said "expected exception". So its good to know and sharing. Thanks.. | |
| Aug 18, 2011 at 6:18 | vote | accept | Vikas | ||
| Aug 18, 2011 at 6:13 | history | answered | mcottle | CC BY-SA 3.0 |