The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test::Module::Runnable - A runnable framework on Moose for running tests

SYNOPSIS

   package YourTestSuite;
   use Moose;
   use Test::More 0.96;

   extends 'Test::Module::Runnable';

   sub helper { } # Not called

   sub testExample { } # Automagically called due to 'test' prefix.

   package main;

   my $tester = new YourTestSuite;
   plan tests => $tester->testCount;
   foreach my $name ($tester->testMethods) {
     subtest $name => $tester->$name;
   }

alternatively...

   my $tester = new YourTestSuite;
   return $tester->run;

DESCRIPTION

A test framework based on Moose introspection to automagically call all methods matching a user-defined pattern. Supports per-test setup and tear-down routines and easy early "BAIL_OUT" in Test::Builder using Test::More.

ATTRIBUTES

sut

System under test - a generic slot for an object you are testing, which could be re-initialized under the setUp routine, but this entry may be ignored.

PRIVATE ATTRIBUTES

__unique_default_domain

The internal default domain value. This is used when unique is called without a domain, because a key cannot be undef in Perl.

__unique

Tracks the counter returned by unique. Always contains the previous value returned, or zero before any calls. A hash is used to support multiple domains.

__random

Hash of random numbers already given out.

METHODS

setUpBeforeClass

Placeholder method called before any test method is called, in order for you to initialize your tests.

unique

Returns a unique, integer ID, which is predictable.

An optional $domain can be specified, which is a discrete sequence, isolated from anhy other domain. If not specified, a default domain is used. The actual name for this domain is opaque, and is specified by "__unique_default_domain".

A special domain; rand can be used for random numbers which will not repeat.

pattern

The pattern which defines which user-methods are considered tests. Defaults to ^test Methods matching this pattern will be returned from "methodNames"

logger

A generic slot for a loggger, to be initialized with your logging framework, or a mock logging system.

This slot is not touched by this package, but might be passed on to your "sut", or you may wish to clear it between tests by sub-classing this package.

mocker

This slot can be used during "setUpBeforeClass" to set up a Test::MockModule for the sut class being tested. If set, mocker-unmock_all()> will be called automagically, just after each test method is executed. This will allow different methods to to be mocked, which are not directly relevant to the test method being executed.

By default, this slot is undef

methodNames

Returns a list of all names of test methods which should be called by subtest, ie. all method names beginning with 'test', or the user-defined pattern.

If you use run, this is handled automagically.

methodCount

Returns the number of tests to pass to plan If you use run, this is handled automagically.

run

Executes all of the tests, in a random order An optional override may be passed with the tests parameter.

  * tests
    An ARRAY ref which contains the inclusive list of all tests
    to run.  If not passed, all tests are run. If an empty list
    is passed, no tests are run.  If a test does not exist, C<confess>
    is called.

  * n
    Number of times to iterate through the tests.
    Defaults to 1.  Setting to a higher level is useful if you want to
    prove that the random ordering of tests does not break, but you do
    not want to type 'make test' many times.

Returns: The return value is always EXIT_SUCCESS, which you can pass straight to exit

debug

Call Test::Builder::diag with a user-defined message, if and only if the TEST_VERBOSE environment variable is set.

AUTHOR

Duncan Ross Palmer, 2E0EOL mailto:palmer@overchat.org

LICENCE

Daybo Logic Shared Library Copyright (c) 2015-2017, Duncan Ross Palmer (2E0EOL), Daybo Logic All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.

    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.

    * Neither the name of the Daybo Logic nor the names of its contributors
      may be used to endorse or promote products derived from this software
      without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

AVAILABILITY

https://bitbucket.org/2E0EOL/libtest-module-runnable-perl

CAVEATS

None known.