A lot of developers I have worked with have been amazed to see that I expand a suite of tests they developed by a factor of four. This is almost always because I am stressing error handling which is often not tested at all. Unfortunately, these tests will often cause many warnings. Sometimes I want to verify the exact warning. Other times it just clutters the output being sent to the screen. This can be very dangerous - it may lead someone running the test to believe there is a newly introduced bug.
Luckily, perl has a well defined mechanism for overriding the warn behavior. If you want to suppress warnings from being displayed in a section of tests do the following:
{ ... }
{
local $SIG{__WARN__}=sub{}; #Temporarily suppress warnings
# Insert test code here
}
Once the scoping ends, whatever warning handler was in effect before will be active again.
September 9, 2008 at 5:04 am
hi,
i m new to testing, i would like to know hw to test already developed code in perl