Hello, Thanks for Test::Class::Moose. I recently took on a legacy code base with a much neglected test suite, so took the opportunity to effectively start over and rebuild using Test::Class::Moose and I've been finding it both usable and useful.
Today I wanted to do some different things in test_setup depending on the tags on the test, so I used the documentation, but the example provided dies:
Full minimal example:
use Test::Class::Moose::Runner;
Test::Class::Moose::Runner->new( test_classes => ['Tag::Test'] )->runtests;
package Tag::Test;
use Test::Class::Moose;
sub test_setup {
my $test = shift;
my $method_to_run = $test->test_report->current_method;
if ( $method_to_run->has_tag('db') ) {
warn "Do db things";
}
else {
warn "Do something else";
}
}
sub test_the_db : Tags( db ) {
ok 1, "test_the_db";
}
sub test_not_the_db {
ok 1, "not the db";
}
Output:
$ prove TCM_test.pl
TCM_test.pl .. 1/1 # Failed test 'Tag::Test->test_setup failed'
# at /usr/local/share/perl/5.22.1/Test/Class/Moose/Role/Executor.pm line 168.
# Can't locate object method "class" via package "Test::Class::Moose::Report::Instance" at /usr/local/share/perl/5.22.1/Test/Class/Moose/Report/Method.pm line 57.
# Failed test 'Tag::Test->test_setup failed'
# at /usr/local/share/perl/5.22.1/Test/Class/Moose/Role/Executor.pm line 168.
# Can't locate object method "class" via package "Test::Class::Moose::Report::Instance" at /usr/local/share/perl/5.22.1/Test/Class/Moose/Report/Method.pm line 57.
# Failed test 'Tag::Test'
# at /usr/local/share/perl/5.22.1/Test2/Tools/AsyncSubtest.pm line 23.
# Looks like you failed 1 test of 1.
TCM_test.pl .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests
Test Summary Report
-------------------
TCM_test.pl (Wstat: 256 Tests: 1 Failed: 1)
Failed test: 1
Non-zero exit status: 1
Files=1, Tests=1, 1 wallclock secs ( 0.03 usr 0.00 sys + 0.53 cusr 0.02 csys = 0.58 CPU)
Result: FAIL
This is true for both version 0.98 and 0.99 on perl v5.22.1 and v5.30.0.
The fix seems simple enough (pull request incoming), but without digging deeper into the Test::Class::Moose testsuite, I'm not sure why it's not already caught. A cursory reading suggests test_me() in t/taglib/TestsFor/Basic.pm ought to catch it (and does, if you run it explicitly), but it appears it might be a "meta" test that is not actually run.
Perhaps someone else can figure that one out more readily than me.
Hello, Thanks for Test::Class::Moose. I recently took on a legacy code base with a much neglected test suite, so took the opportunity to effectively start over and rebuild using Test::Class::Moose and I've been finding it both usable and useful.
Today I wanted to do some different things in test_setup depending on the tags on the test, so I used the documentation, but the example provided dies:
Full minimal example:
Output:
This is true for both version 0.98 and 0.99 on perl v5.22.1 and v5.30.0.
The fix seems simple enough (pull request incoming), but without digging deeper into the Test::Class::Moose testsuite, I'm not sure why it's not already caught. A cursory reading suggests test_me() in t/taglib/TestsFor/Basic.pm ought to catch it (and does, if you run it explicitly), but it appears it might be a "meta" test that is not actually run.
Perhaps someone else can figure that one out more readily than me.