Test::FailWarnings - Add test failures if warnings are caught
version 0.001
Test file:
use strict; use warnings; use Test::More; use Test::FailWarnings; ok( 1, "first test" ); ok( 1 + "lkadjaks", "add non-numeric" ); done_testing;
Output:
ok 1 - first test not ok 2 - Caught warning # Failed test 'Caught warning' # at t/bin/main-warn.pl line 7. # Warning was 'Argument "lkadjaks" isn't numeric in addition (+) at t/bin/main-warn.pl line 7.' ok 3 - add non-numeric 1..3 # Looks like you failed 1 test of 3.
This module hooks $SIG{__WARN__} and converts warnings to Test::More's fail() calls. It is designed to be used with done_testing, when you don't need to know the test count in advance.
$SIG{__WARN__}
fail()
done_testing
Just as with Test::NoWarnings, this does not catch warnings if other things localize $SIG{__WARN__}, as this is designed to catch unhandled warnings.
Test::NoWarnings -- catches warnings and reports in an END block. Not (yet) friendly with done_testing.
END
Test::Warn -- test for warnings without triggering failures from this modules
Please report any bugs or feature requests through the issue tracker at https://github.com/dagolden/test-failwarnings/issues. You will be notified automatically of any progress on your issue.
This is open source software. The code repository is available for public review and contribution under the terms of the license.
https://github.com/dagolden/test-failwarnings
git clone git://github.com/dagolden/test-failwarnings.git
David Golden <dagolden@cpan.org>
This software is Copyright (c) 2013 by David Golden.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
To install Test::FailWarnings, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::FailWarnings
CPAN shell
perl -MCPAN -e shell install Test::FailWarnings
For more information on module installation, please visit the detailed CPAN module installation guide.