View on
MetaCPAN
Dave Rolsky > Test-Class-Moose > Test::Class::Moose::Role

Download:
Test-Class-Moose-0.89.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.89   Source  

NAME ^

Test::Class::Moose::Role - Test::Class::Moose for roles

VERSION ^

version 0.89

DESCRIPTION ^

If you need the functionality of Test::Class::Moose to be available inside of a role, this is the module to do that. This is how you can declare a TCM role:

    package TestsFor::Basic::Role;

    use Test::Class::Moose::Role;

    sub test_in_a_role {
        my $test = shift;

        pass "This is picked up from role";
    }


    sub in_a_role_with_tags : Tags(first){
        fail "We should never see this test";
    }


    sub test_in_a_role_with_tags : Tags(second){
        pass "We should see this test";
    }

    1;

And to consume it:

    package TestsFor::Basic::WithRole;
    use Test::Class::Moose;

    with qw/TestsFor::Basic::Role/;

    sub test_in_withrole {
        pass "Got here";
    }

    1;

Note that this cannot be consumed into classes and magically make them into test classes. You must still (at the present time) inherit from Test::Class::Moose to create a test suite.

Skipping Test::Most

By default, when you use Test::Class::Moose::Role in your own test class, it exports all the subs from Test::Most into your class. If you'd prefer to import a different set of test tools, you can pass bare => 1 when using Test::Class::Moose::Role:

 use Test::Class::Moose::Role bare => 1;

 When you pass this, C<Test::Class::Moose::Role> will not export L<Test::Most>'s subs
 into your class. You will have to explicitly import something like
 L<Test::More> or L<Test2::Tools::Compare> in order to actually perform tests.

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 ^

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2012 - 2017 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.

syntax highlighting: