NAME

Test::Class::Moose::Role::CLI - Role for command line argument handling and extra CLI features

VERSION

version 0.99

SYNOPSIS

package My::CLI;

use Moose;

with 'Test::Class::Moose::Role::CLI';

sub _munge_class {
    return $_[1] =~ /^TestFor::/ ? $_[1] : 'TestFor::MyApp::' . $_[1] );
}

sub _before_run { ... }
sub _after_run { ... }

DESCRIPTION

This role provides the core implementation of command line option processing for Test::Class::Moose::CLI. You can consume this role and add additional hooks to customize how your test classes are run.

See Test::Class::Moose::CLI for a list of all the available command line options that this role handles.

HOOKS

This role has several hook methods that it calls. The role provides no-op or default implementations of these hooks but you can provide an implementation in your class that does something.

_munge_class

This method is called for each class as found by the command line --classes option. Note that this is called after resolving file and directory paths passed as a --classes option.

You can use this to allow people to pass short names like Model::Car and turn it into a full name like TestFor::MyApp::Model::Car.

By default this method is a no-op.

_before_run

This method is called before the test classes are run (or even loaded).

By default this method is a no-op.

_test_lib_dirs

This should return a list of directories containing test classes. The directories can be relative to the project root (t/lib) or absolute.

This defaults to returning a single path, t/lib.

Note that this is now also settable via "--test_lib_dirs" in Test::Class::Moose::CLI.

_load_classes

This method will try to load all the classes passed on the command line if any were passed. If the value that was passed is a path rather than a class name, any leading part matching a value in the list from _test_lib_dirs will be stripped, and the rest will be transformed from a path to a module name.

Otherwise it invokes Test::Class::Moose::Load with the value returned by _test_lib_dirs as its argument.

_after_run

This method is called after all the test classes are run.

By default this method is a no-op.

SUPPORT

Bugs may be submitted at https://github.com/houseabsolute/test-class-moose/issues.

I am also usually active on IRC as 'autarch' on irc://irc.perl.org.

SOURCE

The source code repository for Test-Class-Moose can be found at https://github.com/houseabsolute/test-class-moose.

AUTHORS

  • Curtis "Ovid" Poe <ovid@cpan.org>

  • Dave Rolsky <autarch@urth.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 - 2021 by Curtis "Ovid" Poe.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

The full text of the license can be found in the LICENSE file included with this distribution.