Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

  (email not shown publicly)
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Friday November 13, 2009
12:21 PM

Implicit "done_testing()" in subtests

[ #39892 ]

Per a previous blog entry, I've submitted a pull request on github to implement an implicit done_testing() on subtests with no plan. This is due to the following:

subtest 'trim' => sub {
    plan tests => 2;
    # snip

subtest 'escape' => sub {
    plan tests => 2;
    # snip

subtest 'interior sequences' => sub {
    plan tests => 6;
    # snip

It was getting awfully annoying having to maintain plans for all of the subtests when I could clearly distinguish when a subtest was finished. If the pull request is accepted, you can just do this:

subtest 'some subtest' => sub {
    isa_ok my $cust = Customer->new({
      given  => 'John',
      family => 'Public' }
    ), 'Customer';
    can_ok $cust, 'given';
    is $cust->given, 'John',

    can_ok $cust, 'family';
    is $cust->family, 'Public';

done_testing() will be implicitly called at the end of that (and you can list it explicitly, if you want). This allows you to safely add extra tests to all subtests without worrying about the plan, nor do you have to worry about annoying plan management unless it's really important.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.