NAME
Test::Suite::TestHelper - Make Test::Suite testable
DESCRIPTION
Prevents plugins from producing TAP output and instead provides you with results that would be sent to Test::Suite.
SYNOPSYS
#!/usr/bin/perl
use Test::Suite::TestHelper;
use warnings;
use strict;
use Test::More;
use Data::Dumper;
# Should be in a BEGIN to make testers with prototypes work.
BEGIN {
real_tests { use_ok( 'MyPlugin' ) };
MyPlugin->export_to( __PACKAGE__ );
}
my_tester( ... );
my_other_tester( ... );
my $results = results();
# Actual tests that should produce output must be in a 'real_tests' block.
real_tests {
ok( @$results, "found results" );
};
A single result will follow this format
{
# These are reliable.
result => $TEST_RESULT, # what your custom tester returned
name => $TEST_NAME, # The second item your custom tester returned
time => $RUN_TIME, # How long the test took to run (Timer::HiRes)
debug => \@DEBUG, # If the test failed this should contain
# extra information that should be printed for
# the user (This is all the other elements your
# custom tester returned)
# These should be reliable
package => $PACKAGE, # Package the test was run from
filename => $FILENAME, # Filename test was run from
line => $LINE, # Line number where test was run
# These may or may not be defined
todo => $REASON, # If the test was run in a todo {} block.
# If run under a set/case these will be references to the case/set objects
case => $CASE,
set => $SET,
}
EXPORTS
- $results = results()
- results(1)
-
Returns an arrayref with all the results obtained since results was last cleared. Optional argument tells results() to clear all results.
MAGIC BE HERE
This works by overriding parts of Test::Suite::Plugin so that when called parts of Test::Suite are lexically overriden. There is all kinds of room from problems here, but I am not sure of a better way yet, just be careful.
AUTHORS
Chad Granum exodist7@gmail.com
COPYRIGHT
Copyright (C) 2010 Chad Granum
Test-Suite is free software; Standard perl licence.
Test-Suite is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.