Please don't create tests like this in Perl

I just came across a test like:

And of course, it was silently doing something/nothing/everything. I'd guess most experience Perl coders will notice that the eval will only run the test if the request doesn't throw an exception. Which might be kind of ok but there is no catch or check of the $@ later.

If a check is added for $@ later, it will make the test pattern pretty messy

Please don't write this type of test. Please.

Instead use Test::Exception and drop into a sub. Something along the lines of:

This is better for a couple of reasons:
  • test will show some output in case of exception
  • test will stop instead of just pushing on with a bunch of mostly false error (unless the test wants to this to check bad input :)
  • test is simpler to understand (no response, give up)


  1. Thanks for this amazing post its help me a lot to solve my issues click here to download Kinemaster Mod APK

  2. Nice Post. To get study abroad in any course. For students who is looking for study medicine in abroad, we will help with end to end services with zero cost.
    Mbbs in Russia
    Mbbs in UK
    Mbbs in Malaysia


Post a Comment

Popular posts from this blog

2 ways to get SQLite to put dates into columns

BootstrapX clickover

What's installed on my ec2