Skip to content

Test::Class::Moose::Role::AutoUse and no corresponding base class #33

@Ovid

Description

@Ovid

When I write a base class, it's often something like:

package TestsFor::SomeCompany;

use Test::Class::Moose;
with qw(Test::Class::Moose::Role::Autouse);

1;

That's always worked (so far) because there's almost always a corresponding SomeCompany.pm file. Today that turned out to not be the case. However, we should try to decouple that and have the autouse role recognize when we don't need a corresponding class. This was a coupling mistake I made and am thinking about a clean solution for the fix. Until then, the following workaround in your TCM base class should suffice:

around 'get_class_name_to_use' => sub {
    my $orig = shift;
    my $self = shift;

    if ( __PACKAGE__ eq ref $self ) {
        return '';
    }
    return $self->$orig(@_);
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions