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)
__END__

Comments

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

    ReplyDelete
  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.
    Skolarrssolutions
    Mbbs in Russia
    Mbbs in UK
    Mbbs in Malaysia

    ReplyDelete
  3. clipping path
    Excellent Post. Thanks for Sharing your valuable information.

    Really Outstanding post. I love these. It will useful for any new comer and expert guys also. Thanks for your excellent stuff.

    ReplyDelete
  4. Thanks for your informative article. This article is very informative for us. Thank You for this amazing knowledge.
    Download Call of Duty Mobile Hack Script

    ReplyDelete
  5. Thanks for your informative article. This article is very informative for us. Thank You for this amazing knowledge.
    Download Call of Duty Mobile Hack Script

    ReplyDelete

Post a Comment

Popular posts from this blog

2 ways to get SQLite to put dates into columns

BootstrapX clickover

Bootstrap (by Twitter) loading in page content for Popovers