How do I unit-test some code of mine that needs to raise errors? I find this very problematic, since usually the first simple conditions that are the easiest to test and code are the error sitations. But my test cannot, and should not, stop the error from being raised. What can I do to solve this? ---- Your tests should bring your units to throw the exception and catch it. If no exception is thrown, the test should fail. testDivision() { try { 1/0; fail(); } catch (DivisionByZero e) { success(); } }