Hi,
I'm looking for comment or suggestions about this new module. It's
independent of and complementary to Test::Warn. It tests that your test
script didn't emit any warnings. Just add
use Test::More::None;
to the top your test script, update your plan (if you've got one) and that's
it. You'll get an extra test, executed after your script ends checking
whether there were any warnings. If there were you'll get a full run down of
them including a stack trace.
If there are parts of your script that should be emitting warnings then you
should be using Test::Warn to capture them, the 2 modules should play nicely
together.
Full docs below.
F
NAME
Test::Warn::None - Make sure you didn't emit any warnings while testing
SYNOPSIS
use Test::Warn::None;
# do lots of testing
DESCRIPTION
In general, your tests shouldn't produce warnings. This allows you to
check at the end of the script that they didn't. If they did produce
them, you'll get full details including a stack trace of what was going
on when the warning occurred.
If some of your tests should produce warnings then you should be
capturing and checking them with Test::Warn, that way Test::Warn::None
will not see them and not complain.
USAGE
Simply by using the module, you automatically get an extra test at the
end of your script that checks that no warnings were emitted. So just
stick
use Test::Warn::None
at the top of your script and continue as normal.
If you want more control you can invoke the test manually at any time
with "had_no_warnings()".
The warnings your test has generated so far are stored are in array. You
can look inside and clear this whenever you want with "warnings()" and
"clear_warnings()". However, it would be better to use the Test::Warn
module if you want to go poking around inside the warnings.
OUTPUT
If warning is captured during your test then the details will output as
part of the diagnostics. You will get:
o the number and name of the test that was executed just before the
warning (if no test had been executed these will be 0 and '')
o the message passed to "warn",
o a full dump of the stack when warn was called, courtesy of the "Carp"
module
EXPORTABLE FUNCTIONS
had_no_warnings()
This checks that there have been warnings emitted by your test scripts.
Usually you will not call this explicitly as it is called automatically
when your script finishes.
clear_warnings()
This will clear the array of warnings that have been captured. If the
array is empty then a call to "had_no_warnings()" will produce a pass
result.
warnings()
This will return the array of warnings captured so far. Each element of
this array is a hashref with the following keys:
o prev_test: the number of the test that executed before the warning was
produced, if no tests had executed, this will be 0.
o prev_test_name: the name of the test that executed before the warning
was produced, if no tests had executed, this will be "".
o msg: the captured warning message that your test emitted
o carp: the captured warning message that your test emitted plus a stack
trace generated by the Carp module.
o stack_trace: A Devel::StackTrace object, created at the time of the
warning. This will only be present if Devel::StackTrace is installed.
PITFALLS
When counting your tests for the plan, don't forget to include the test
that runs automatically when your script ends.
BUGS
None that I know of.
SEE ALSO
Test::More, Test::Warn
AUTHOR
Written by Fergal Daly <[EMAIL PROTECTED]>.
COPYRIGHT
Copyright 2003 by Fergal Daly <[EMAIL PROTECTED]>.
This program is free software and comes with no warranty. It is
distributed under the LGPL license
See the file LGPL included in this distribution or
http://www.fsf.org/licenses/licenses.html.