in reply to Testing test function
Test::More comes with Test::Builder::Tester for testing testing modules. It's horrible. Just horrible.
Use Test::Tester instead. Here's an example of using Test::Tester to test the is_deeply function from Test::More, and make sure there isn't some insane bug in is_deeply that nobody's ever noticed...
use strict; use warnings; use Test::Tester; use Test::More 0.96; subtest "two identical structures" => sub { my (undef, $result1) = run_tests sub { is_deeply( [1,2,3], [1..3] +) }; ok( $result1->{ok}, 'is_deeply passes', ); is( $result1->{diag}, '', 'no unnecessary diagnostics printed', ); done_testing; }; subtest "two different structures" => sub { my (undef, $result2) = run_tests sub { is_deeply( [1,3], [1..3] ) +}; ok( !$result2->{ok}, 'is_deeply fails' ); like( $result2->{diag}, qr{Structures begin differing}, 'expected diagnostics ok' ); done_testing; }; done_testing;
TL;DR: run_tests runs some tests in a coderef, captures the TAP output, and turns it into a list of hashrefs of test results. You can then use plain old Test::More functions to test those test results.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Testing test function
by sedusedan (Pilgrim) on Sep 27, 2013 at 06:24 UTC | |
|
Re^2: Testing test function
by sedusedan (Pilgrim) on Sep 27, 2013 at 17:20 UTC |