in reply to Re: Re: Keeping SKIP Test Blocks Under Control
in thread Keeping SKIP Test Blocks Under Control
That makes me want to write Test::Skip that wraps ok(), is(), like() and so on to avoid having to duplicate the test name.
Hmmm. Interesting thought. I think you could just get away with something like this:
sub skip_unless (&$$) { my ($test, $name, $tests_to_skip) = @_; local $Test::Builder::Level = $Test::Builder::Level+1; my $passed; my $ok = \&Test::Builder::ok; { no warnings; local *Test::Builder::ok = sub { $_[2] = $name unless defined $_[2]; $ok->(@_); }; use warnings; $passed = $test->(); }; skip "failed: $name", $tests_to_skip unless $passed; return $passed; };
allowing you to do things like:
skip_unless { ok $mech->is_html } 'Returns HTML', 3; .... skip_unless { is $foo, $bar } 'foo == bar', 3; ...
So you wouldn't have to have N different *_or_skip routines. Not sure whether this would deserve a module all of its own though...
|
|---|