examples/perl/t/fibonacci_with_warnings.t
use strict;
use warnings;

use Test::More tests => 5 + 1;
use Test::NoWarnings;
use Test::Warn;

use lib 'lib';
use MyTools;


{
    my $result = other_fibo(2);
    is($result, 1, 'fibonacci on 2');
}

{
    my $result;
    warning_is {$result = fibonacci(-1)} "Given number must be > 0",
        'warning when called with -1';
    is($result, 0, 'fibonacci on -1 returns 0');
}

{
    my $result = other_fibo(4);
    is($result, 3, 'fibonacci on 4');
}

{
    my $result = other_fibo(6);
    is($result, 8, 'fibonacci on 6');
}


sub other_fibo {
    warn "Some other warning @_";
    fibonacci(@_);
}

Output:

examples/perl/t/fibonacci_with_warnings.out
1..6
ok 1 - fibonacci on 2
ok 2 - warning when called with -1
ok 3 - fibonacci on -1 returns 0
ok 4 - fibonacci on 4
ok 5 - fibonacci on 6
not ok 6 - no warnings
#   Failed test 'no warnings'
#   at /home/gabor/perl/lib/site_perl/5.14.2/Test/NoWarnings.pm line 45.
# There were 3 warning(s)
#   Previous test 0 ''
#   Some other warning 2 at t/fibonacci_with_warnings.t line 36.
#  at t/fibonacci_with_warnings.t line 36.
#   main::other_fibo(2) called at t/fibonacci_with_warnings.t line 13
#
# ----------
#   Previous test 3 'fibonacci on -1 returns 0'
#   Some other warning 4 at t/fibonacci_with_warnings.t line 36.
#  at t/fibonacci_with_warnings.t line 36.
#   main::other_fibo(4) called at t/fibonacci_with_warnings.t line 25
#
# ----------
#   Previous test 4 'fibonacci on 4'
#   Some other warning 6 at t/fibonacci_with_warnings.t line 36.
#  at t/fibonacci_with_warnings.t line 36.
#   main::other_fibo(6) called at t/fibonacci_with_warnings.t line 30
#
# Looks like you failed 1 test of 6.

It shows that there were warnings generated during the tests. It even tells us at wich test. The biggest problem with this module is that it does not work together with done_testing() and so it requires that you know how many test you are going to run.