Subject: | Error when Moose loaded by module other than tested module |
Date: | Fri, 2 Jan 2015 15:51:59 +0000 |
To: | bug-Test-TestCoverage [...] rt.cpan.org |
From: | Colin Robertson <colin.robertson [...] zpg.co.uk> |
Tested with:
- Perl v5.16.3
- Test::TestCoverage 0.11
- Moose 2.1005
When Moose is loaded by a module other than the one being tested for
coverage (e.g. in a dependency), Test::TestCoverage dies with the following
message:
Can't call method "add_after_method_modifier" on an undefined value at
/usr/local/share/perl5/Test/TestCoverage.pm line 65.
This can be reproduced with the following code:
test.pl:
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 3;
use Test::TestCoverage;
use_ok('Foo');
test_coverage('Foo');
is(Foo::fortytwo(),42,"fortytwo");
ok_test_coverage('Foo');
----
Foo.pm:
package Foo;
use Bar;
sub fortytwo { 42 }
1;
----
Bar.pm:
package Bar;
use Moose;
1;
----
Which gives the output:
1..3
ok 1 - use Foo;
Can't call method "add_after_method_modifier" on an undefined value at
/usr/local/share/perl5/Test/TestCoverage.pm line 65.
# Looks like you planned 3 tests but ran 1.
# Looks like your test exited with 255 just after 1.
If I comment out the 'use Moose;' line, then it works correctly:
1..3
ok 1 - use Foo;
ok 2 - fortytwo
ok 3 - Test test-coverage
--
*Colin Robertson*
Software Developer, ZPG
T - 020 7620 4679
F - 0207 620 4770
E - colin.robertson@zpg.co.uk <colin.robertson@zoopla.co.uk>
www.zpg.co.uk
Zoopla Property Group Plc, Registered address: Harlequin Building, 65
Southwark Street, London SE1 0HR. Registered in England and Wales with
Company No. 09005884
www.zoopla.co.uk | www.primelocation.com | www.smartnewhomes.com |
www.homesoverseas.co.uk
The information in this email is confidential and is intended solely for
the addressee. Access to this email by anyone else is unauthorised. If you
have received this email in error please advise ZPG immediately and delete
it. Any disclosure, copying or distribution of this email, or reliance
placed upon it, by unauthorised recipients is prohibited and may be
unlawful.