开发者

Is it possible to have a test soft fail in Perl?

Is it possible to have a soft fail of a test in 开发者_如何学运维Perl? by soft fail I mean the test fails, but it will not cause the test suite to fail.


This may help ... You can mark a block of tests as 'TODO' like this:

#!/usr/bin/perl

use strict;
use warnings;

use Test::More;

ok(1);

TODO: {
    local $TODO = 'is_odd() implementation still flakey';

    is( is_odd(3), 1, '3 is odd' );
};


done_testing();


sub is_odd {
  return rand() > 0.5 ? 1 : 0;
}

Whether the tests in the TODO block pass or fail will not affect the result for the script. However if the tests do pass, the summary output from prove will tell you which test passed 'unexpectedly'. The verbose output from prove -v will give full diagnostic details for all the tests including failing TODO tests.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜