perlunit-testingtestingtest-more

Report only failed tests in Test::More


I have a lot of checks for random generated data. How can I get report message only for failed tests and show nothing if check is ok?


Solution

  • You can use the fail routine. Make your checks outside of any Test::More code and use that result to decide if you output test messages.

    foreach my $element ( @randomly_generated_data ) {
        my $result = ...; # your checks here
        next if $result;
        fail( 'Some message' );
        }