Debugging code using UnitTests

James Avery makes a great point in his post about multiple assertions in unit tests.  I really like the concept of being able to run multiple asserts within a given testcase and having them all run, even if one fails. However, I would like an additional argument (boolean – “exitOnFailure”) for the Assert methods so that I can elect to abort a test if the assert fails

Using multiple asserts in this manner would really extend the concept of UnitTests, making it easier to trace what was the likely cause of a test failure.  Instead of looking at all the tests that failed to try and pinpoint the root cause (in a similar way to looking at all the compile errors to try to identify the single error that is causing them all), you could look at a test case and analyse the assertions to narrow down the cause.

Great idea James!

Leave a comment