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 (via use, do or require) 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) # => Object 

Exit code, representing the status of the test run.

Returns:

    Exit code, representing the status of the test run.

filter
- filter($self) # => Object 

Test name filter.

Returns:

    Test name filter.

logger
- logger($self) # => Object 

Logger instance.

Returns:

    Logger instance.

seed
- seed($self) # => Object 

Randomness seed.

Returns:

    Randomness seed.

verbose
- verbose($self) # => Object 

Logger verbosity.

Returns:

    Logger verbosity.

Test Run Hooks

run
- run($self) # => Object 

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:

run_test
- run_test($self, $tc, $test) # => Integer 

Runs a specific test.

Parameters:

    $tc (Class) - The test case owning the test method.

    $test (String) - 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) # => Object 

Runs tests in a test case.

Parameters:

    $tc (Class) - The test case to run.

    @tests (Array<String>) - A list of tests to be run.

run_test_suite
- run_test_suite($self, %args) # => Object 

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:

    %args (Hash)

Valid Options for %args:

    filter (String) - Test name filter.

    seed (String) - Randomness seed.

Returns:

Callbacks

error
- error($self, $tc, $test, $e) # => Object 

Callback for dying tests.

Parameters:

    $tc (Class) - The test case owning the test method.

    $test (String) - The name of the test with an error.

    $e (Test::Mini::Exception) - The exception object.

fail
- fail($self, $tc, $test, $e) # => Object 

Callback for failing tests.

Parameters:

    $tc (Class) - The test case owning the test method.

    $test (String) - The name of the failed test.

    $e (Test::Mini::Exception::Assert) - The exception object.

pass
- pass($self, $tc, $test) # => Object 

Callback for passing tests.

Parameters:

    $tc (Class) - The test case owning the test method.

    $test (String) - The name of the passing test.

skip
- skip($self, $tc, $test, $e) # => Object 

Callback for skipped tests.

Parameters:

    $tc (Class) - The test case owning the test method.

    $test (String) - The name of the skipped test.

    $e (Test::Mini::Exception::Skip) - The exception object.

Class Methods

new
+ new($class, %args) # => Object 

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:

    %args (Hash) - Initial state for the new instance.

Valid Options for %args:

    verbose - Logger verbosity. Defaults to 0.

    filter (String) - Test name filter. Defaults to ''.

    logger (Class) - Logger class name. Defaults to Test::Mini::Logger::TAP.

    seed (Integer) - Randomness seed. Defaults to a random number < 64_000_000 .