sub subtest

Documentation for sub subtest assembled from the following types:

module Test

From Test

(Test) sub subtest

Defined as:

multi sub subtest(Pair $what)
multi sub subtest($desc&subtests)
multi sub subtest(&subtests$desc = '')

The subtest function executes the given block, consisting of usually more than one test, possibly including a plan or done-testing, and counts as one test in plan, todo, or skip counts. It will pass the test only if all tests in the block pass. The function accepts an optional description of the subtest.

class Womble {}
 
class GreatUncleBulgaria is Womble {
    has $.location = "Wimbledon Common";
    has $.spectacles = True;
}
 
subtest {
    my $womble = GreatUncleBulgaria.new;
 
    isa-ok $womble,            Womble,             "Correct type";
    is     $womble.location,   "Wimbledon Common""Correct location";
    ok     $womble.spectacles,                     "Correct eyewear";
 
}"Check Great Uncle Bulgaria";

You can also place the description as the first positional argument, or use a Pair with description as the key and subtest's code as the value. This can be useful for subtests with large bodies.

subtest 'A bunch of tests'{
    plan 42;
    ...
    ...
}
 
subtest 'Another bunch of tests' => {
    plan 72;
    ...
    ...
}