On 1/30/07, Nadim Khemir <[EMAIL PROTECTED]> wrote:
I believe the example in Test::Exception is not as good as it could be.# Check that something did not die lives_ok { $foo->method2 } 'expecting to live'; Doesn't explain much about when to use it.
You'd use (lives|dies|throws)_ok when your test is about whether or not something throws an exception. Most of my tests are not about testing exception throwing behavior. I don't put that in "lives_ok" blocks just to prevent unexpected exceptions because while it's true that I hope not to get exceptions, it isn't the primary topic at hand. When I'm testing if, how, and when exceptions get thrown then I *will* use lives_ok not because it's substantially better than just not trapping errors but because it expresses the idea that I'm thinking about the idea that the code won't throw an exception. It says "The point to this code is that it will not throw an exception." I could also say that in adjacent comments or in the name for the test and I frequently will but I value having code that expresses my intent and is not purely function driven. Josh
