NAME
Test::Mini::Runner - Default Test Runner
DESCRIPTION
The Test::Mini::Runner is responsible for finding and running the appropriate tests, setting up output logging, and returning an appropriate status code. For those looking to write tests with this framework, the points of note are as follows:
Tests are run automatically at process exit.
All test cases (subclasses of Test::Mini::TestCase) that have been loaded at that time will be considered. This includes indirect subclasses.
Within each test case, all methods defined with a name matching
/^test.+/
will be run.Each test will run in its own test case instance.
Tests will be run in random order.
#setup will be called before each test is run.
#teardown will be called after each test is run.
Inherited tests are not run.
Tests may be run via
`prove`
, by loading (viause
,do
orrequire
) the files into another script, or by simply executing a file containing a test case in the Perl interpreter.If you want to use a non-TAP output logger,
`prove`
is not an option.
Options may be passed in either as command line options, or as environment variables.
Environment variable names are prefixed with 'TEST_MINI_'.
Valid options are:
verbose
- Specifies the logger's verbosity.
filter
- Only tests with names matching this pattern should be run.
logger
- Specifies an alternate output logger class.
seed
- Specifies a random number seed; used to specify repeatable test orderings.
METHODS
Attribute Accessors
- exit_code
-
exit_code($self)
Exit code, representing the status of the test run.
Returns:
Exit code, representing the status of the test run.
- filter
-
filter($self)
Test name filter.
Returns:
Test name filter.
- logger
-
logger($self)
Logger instance.
Returns:
Logger instance.
- seed
-
seed($self)
Randomness seed.
Returns:
Randomness seed.
- verbose
-
verbose($self)
Logger verbosity.
Returns:
Logger verbosity.
Test Run Hooks
- run
-
run($self)
Begins the test run. Loads and instantiates the test output logger, then dispatches to #run_test_suite (passing the #filter and #seed, as appropriate).
Returns:
The result of the #run_test_suite call.
- run_test
-
run_test($self, $tc, $test) # => Integer
Runs a specific test.
Parameters:
(Class)
$tc
-- The test case owning the test method.(String)
$test
-- The name of the test method to be run.
Returns:
(Integer) -- The number of assertions called by the test.
- run_test_case
-
run_test_case($self, $tc, @tests)
Runs tests in a test case.
Parameters:
(Class)
$tc
-- The test case to run.(Array<String>)
@tests
-- A list of tests to be run.
- run_test_suite
-
run_test_suite($self, %args)
Runs the test suite. Finds subclasses of Test::Mini::TestCase, and dispatches to #run_test_case with the name of each test case and a list test methods to be run.
Parameters:
(Hash)
%args
Valid Options for
%args
:(String) filter -- Test name filter.
(String) seed -- Randomness seed.
Returns:
The value of #exit_code.
Callbacks
- error
-
error($self, $tc, $test, $e)
Callback for dying tests.
Parameters:
(Class)
$tc
-- The test case owning the test method.(String)
$test
-- The name of the test with an error.(Test::Mini::Exception)
$e
-- The exception object.
- fail
-
fail($self, $tc, $test, $e)
Callback for failing tests.
Parameters:
(Class)
$tc
-- The test case owning the test method.(String)
$test
-- The name of the failed test.(Test::Mini::Exception::Assert)
$e
-- The exception object.
- pass
-
pass($self, $tc, $test)
Callback for passing tests.
Parameters:
(Class)
$tc
-- The test case owning the test method.(String)
$test
-- The name of the passing test.
- skip
-
skip($self, $tc, $test, $e)
Callback for skipped tests.
Parameters:
(Class)
$tc
-- The test case owning the test method.(String)
$test
-- The name of the skipped test.(Test::Mini::Exception::Skip)
$e
-- The exception object.
Class Methods
- new
-
new($class, %args)
Constructor. Arguments may be provided explicitly to the constructor or implicitly via either @ARGV (parsed by Getopt::Long) or environment variables ("TEST_MINI_$option").
Parameters:
(Hash)
%args
-- Initial state for the new instance.
Valid Options for
%args
:verbose -- Logger verbosity. Defaults to
0
.(String) filter -- Test name filter. Defaults to
''
.(Class) logger -- Logger class name. Defaults to
Test::Mini::Logger::TAP
.(Integer) seed -- Randomness seed. Defaults to a random number
< 64_000_000
.