assert_raise (on Ruby) - Don't Just Say No
This post introduces developer tests that constrain
exceptions. Our platform, as usual, is Ruby, yet these topics
apply to any system. We will extend
for more control over program faults.
The best developers write tests to keep their projects on track. Tests should cover every aspect of a program, and should take special care with program details that are sticky, hard, and mysterious. Exception handling is a murky topic, because when a program fails its control flow might not be obvious. Many a program has failed in the field because nobody in the lab tested all its error paths. Our test cases must ensure that faults make our programs degrade gracefully, not derail.
|A very helpful article that put a place in the jigsaw for me, looking to use test transactions and errors for the first time. I have incorporated the basic information here, but still need to go on and figure out how to test against the Rails generated errors (eg. validation errors raised by save!). MIght be useful if that were also covered in the article. I am bookmarking the assert_raise_message as likely to be useful in the future. Thanks|