NAME

Test::Builder2::Tester - Testing a Test:: module

SYNOPSIS

    use Test::More;
    use Your::Test::Module qw(this_ok that_ok);
    use Test::Builder2::Tester;

    my $capture = capture {
        this_ok $this, "some name";
        that_ok $that;
    };

    # The first one passed, and it has a name
    result_like $capture->results->[0], {
        is_pass => 1,
        name => "some name",
    };

    # The second one failed, and it has no name
    result_like $capture->results->[1], {
        is_pass => 0,
        name => ''
    };

DESCRIPTION

This is a module for testing Test modules.

Exports

These are exported by default

capture

    my $capture = capture { ...test code ... };

Captures all the events and results which happens inside the block.

Returns a Test::Builder2::Tester::Capture (which is largely a Test::Builder2::History) that you can reference later.

event_like

  event_like( $event, $want );
  event_like( $event, $want, $name );

Tests that a $result looks like what you $want.

$want is a hash ref of keys and values. Each of these will be checked against the $result's attributes. For example...

    result_like( $result, { name => "foo" } );

will check that $result->name eq "foo".

Values can also be regular expressions.

    result_like( $result, { name => qr/foo/ } );

will check that $result->name =~ /foo/.

result_like

  result_like( $result, $want );
  result_like( $result, $want, $name );

Works just as event_like but it also checks the $result is a result.