Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Marking failing tests as TODO by number

by liz (Monsignor)
on Jan 12, 2004 at 21:23 UTC ( #320781=snippet: print w/ replies, xml ) Need Help??

Description: Sometimes when writing tests, some tests may fail. You can mark these tests as TODO with Test::More, but this is only convenient for a single range of tests.

Sometimes a few tests may fail inside a set of nested loops. But marking them in the flow of the program is very complicated.

This little sub allows you to specify which tests are supposed to fail, specified by test number and reason for the failure. For example:

my %todo = ( 1023 => "d f g still fails, but it's not that important", 1567 => 'yikes, we need to fix this one!', ); foreach my $foo (@foo) { foreach my $bar (@bar) { foreach my $car (@car) { todo_some( \%todo,\&ok,func($foo,$bar,$car),"check result +of function" ); } } }
=head2 todo_some

Execute given test subroutine while setting $TODO flag for given
test numbers.

  IN: 1 hash reference, with testnumber / reason strings pairs
      2 reference to subroutine to execute test
      3..N parameters to pass to test subroutine
 OUT: 1 whatever test sub returns

=cut

my $Test = Test::Builder->new; # so we don't need to do it over and ov
+er again
sub todo_some {
    local $TODO = shift->{$Test->current_test + 1} || '';
    no strict 'subs';
    my $sub = shift;
    $sub->( @_ );
} #todo_some
Comment on Marking failing tests as TODO by number
Download Code

Back to Snippets Section

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://320781]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (13)
As of 2014-09-17 13:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (80 votes), past polls