XP is just a number | |
PerlMonks |
Test::Class::Moose ignores my testsby 1arryb (Acolyte) |
on Jul 21, 2014 at 17:53 UTC ( [id://1094535]=perlquestion: print w/replies, xml ) | Need Help?? |
1arryb has asked for the wisdom of the Perl Monks concerning the following question: Hi Monks, Full disclosure: I am new to both Moose and Test::Class::Moose. I'm trying to get Ovid's first example from here working. The example compiles and runs, but attempts to test itself (or at least, one of its internal dependencies) instead of my Person class. I'm running perl 5.18.2 on a brand-new Fedora Core 20 installation. The code: t/lib/Person.pm use Modern::Perl '2014'; package Person; use Moose; use namespace::autoclean; has 'first_name', 'last+nanme' => ( is => 'ro', isa => 'Str', required => 1, ); sub full_name { my $self = shift; return join ' ' => $self->first_name, $self->last_name; } __PACKAGE__->meta->make_immutable; 1; t/lib/My/Test/Class.pm use Modern::Perl '2014'; use Test::Class::Moose; INIT { Test::Class::Moose->new( show_timing => 0, randomize => 0, statistics => 1, )->runtests; } 1; tt/lib/TestsFor/Person.pm use Modern::Perl '2014'; # Note: I had to include this line to get it to compile. # "prove -l tt/lib ... didn't cut it. use lib 'tt/lib'; package TestsFor::Person; use Test::Class::Moose parent => 'My::Test::Class'; sub test_constructor { my $test = shift; my $class = $test->class->name; ok my $person = Person->new( first_name => 'Bob', last_name => 'Dobbs', ), 'We should have a test person'; isa_ok $person, $class, '... and object it returns'; is $person->full_name, 'Bob Dobbs', '... and it should report the correct full name'; } 1; Here's what I get when I run it: $ prove -lv tt/lib/TestsFor/Person.pm tt/lib/TestsFor/Person.pm .. 1..1 # # Running tests for Module::Runtime # # Subtest: Module::Runtime 1..0 # SKIP Skipping 'Module::Runtime': no test methods found ok 1 # skip Skipping 'Module::Runtime': no test methods found # Test classes: 1 # Test methods: 0 # Total tests run: 0 ok All tests successful. Files=1, Tests=1, 1 wallclock secs ( 0.03 usr 0.01 sys + 0.61 cusr 0.02 csys = 0.67 CPU) Result: PASS What am I doing wrong? Thanks, Larry
Back to
Seekers of Perl Wisdom
|
|