Hi,
I'm not very strong on these Test::* modules. Here's the demo script (that should run on any machine that has Test::More and Test::Class installed):
package MyTest;
use warnings;
use base q{Test::Class};
use Test::More 'no_plan';
sub DEMO_1 : Tests
{
my $self = shift;
$self->builder->skip('Wanting to skip the DEMO_1 tests');
my $results = {
'1 / 2' => "0.5",
'1 / 4' => 0.25,
};
_verify($results);
}
sub DEMO_2 : Tests
{
my $results = {
'1 / 8' => "0.125",
'1 / 16' => 0.0625,
};
_verify($results);
}
Test::Class->runtests;
sub _verify {
my $results = shift;
for(keys(%$results)) {
ok( eval($_) == $results->{$_}, "$_ == $results->{$_}");
}
}
And here's the output I get on Win32, perl-5.10.0:
ok 1 # skip Wanting to skip the DEMO_1 tests
ok 2 - 1 / 4 == 0.25
ok 3 - 1 / 2 == 0.5
ok 4 - 1 / 8 == 0.125
ok 5 - 1 / 16 == 0.0625
1..5
Now that's not quite what I intend. To begin with, the
$self->builder->skip('Wanting to skip the DEMO_1 tests'); seems to be treated as a test (that passes) in itself. I'm not so concerned about that. What does concern me is that the 2 tests that I want to skip (namely, the 2 tests in sub DEMO_1) are still being run.
Is that a bug in Test::Builder ? ... perhaps as a result of the Test::Class environment ? ... or is it a Test::Class bug ? ... or is it just plain ol' incorrect usage on my part ?
Now, I've found a solution to the problem using the Test::More SKIP{} block. But is there a way I can get the sub DEMO_1 tests skipped by using that "$self->builder->skip()" approach ? Is there some other way of getting the desired result using Test::Builder::skip() ?
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.