NAME
Test::Mini::Runner - default test runner for Test::Mini test cases
DESCRIPTION
This module 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.
The
setup()
method will be called before each test is run.The
teardown()
will be called after each test is run.Inherited tests are not run.
Tests may be run via prove, by loading (via
use
,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.
CLASS METHODS
new(%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
).
The following arguments are supported:
- verbose
-
Logger verbosity. Defaults to 0.
- filter
-
Test name filter. Defaults to ''.
- logger
-
Logger class name. Defaults to Test::Mini::Logger::TAP.
- seed
-
Randomness seed. Defaults to a random number
< 64_000_000
.
ATTRIBUTE ACCESSORS
exit_code
Returns the exit code, representing the status of the test run.
filter
Test name filter.
logger
Logger instance.
seed
Randomness seed.
verbose
Logger verbosity
TEST RUN HOOKS
run
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($tc, $test)
Runs a specific test. Takes two arguments, which identify the test to run:
Returns the number of assertions called by the test.
run_test_suite(%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.
Can be passed a hash of arguments; the following keys are understood:
Returns the value of exit_code()
.
CALLBACKS
error($tc, $test, $e)
Callback for dying tests. Takes three arguments:
$tc
- the test case owning the test method.$test
- the name of the failed test.$e
- the exception object, an instance of Test::Mini::Exception::Assert.
pass($tc, $test)
Callback for passing tests. Takes two arguments: $tc
is the test case owning the test method, and $test
is the name of the passing test.
skip($tc, $test, $e)
Callback for skipped tests. The arguments are the same as those for the error()
method, above.
SEE ALSO
REPOSITORY
https://github.com/pvande/Test-Mini
AUTHOR
Pieter van de Bruggen <pvande@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Pieter van de Bruggen <pvande@cpan.org>
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.