Jamie Beverly > OOP-Perlish-Class-0.45.0 > OOP::Perlish::Class::AutoTest

Download:
OOP-Perlish-Class-0.45.0.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Source  

NAME ^

OOP::Perlish::Class::AutoTest

SUMMARY ^

    #!/usr/bin/perl
    use warnings;
    use strict;

    use blib;
    use OOP::Perlish::Class::AutoTest (tests => [ 'UnitTests' ], package => [ 'OOP::Perlish::Class' ], exclude => [ '^Base.pm$' ]);
    OOP::Perlish::Class::AutoTest->runtests();

DESCRIPTION ^

Automatically find unittests in @INC for specified package(s) and run them

Unittests must be derived from Test::Class.

See OOP::Perlish::Class distrubution for complete examples. Below are some highlights:

METHODS ^

runtests

Run all unittests found for given packages

LOCATIONS ^

This module makes the following assumptions about the location of unit tests with relationship to the classes they test:

Given the module location /path/to/My/Class.pm Unit tests will be in /path/to/My/Class/<test-identifier-path>/*.pm

So, for example, if I choose as test-identifier-paths 'UnitTests' and 'SmokeTests', then all my tests would be in:

 /path/to/My/Class/UnitTests/*.pm
 /path/to/My/Class/SmokeTests/*.pm

Any module found in those path locations will automatically be run with the lines:

 use OOP::Perlish::Class::AutoTest (tests => [ 'UnitTests', 'SmokeTests', ], package => 'My::Class' );
 OOP::Perlish::Class::AutoTest->runtests();

EXAMPLE ^

 #!/usr/bin/perl
 use warnings;
 use strict;

 use blib;
 use OOP::Perlish::Class::AutoTest (tests => [ 'UnitTests' ], package => 'My::Class', exclude => [ '^Base.pm$' ]);
 OOP::Perlish::Class::AutoTest->runtests();
tests

A listref of directory names in @INC where you can find tests for each 'package'. The assumption is that these tests will exist as a subdirectory of the class itself, so for instance, the tests for My::Class are in OOP/Perlish/Class/UnitTests/*, in the same location as My::Class itself.

This assumption is important, because this module determines where My::Class was used from, and does a 'find' on that directory to look for paths matching each item in tests = []>.

Note that you can include a single string in lieu of a listref, which will be treated as a listref containing only a single member.

package

The next list is the list of packages to test. This allows you to have every unit-test for the same component run out of the same file. So if you have a class hiarchy which makes sense to test all at once, you could list them all with package = [ 'My::Class', 'My::Class::Thing' ]>. For each 'package', all subdirectories matching names in tests = []> will be searched.

Note that you can include a single string in lieu of a listref, which will be treated as a listref containing only a single member.

I chose not to pluralize this parameter, as it almost always only makes sense to test a single class at a time.

exclude

A listref wherein you can include regular expression patterns for files you wish to exclude. This useful for things like base-classes which your test-classes are derived from, but are not themselves test classes. Specifying multple items in the listref is identical to providing a pattern with each element logically ORed together [e.g. (?:foo|bar) ]

syntax highlighting: