in reply to Re^3: Checking parameters passed to a third party module during testing (wrap)
in thread Checking parameters passed to a third party module during testing
sub MIME::Lite::new { my ($self, %params) = @_; ok (exists $params{To}, 'To address present'); ok ($params{To} eq 'wibble@wobble', 'To address correct'); ... goto $new; # <-------------- }
You'd be making use of the goto &NAME functionality (see perldoc -f goto), where your wrapper for Mime::Lite::new() gets replaced on the call stack with the real Mime::Lite::new, which was saved in $new. The goto-ed function is called with the contents of @_. According to the perldoc:
After the "goto", not even "caller" will be able to tell that this routine was called first.
The consequence of using goto makes your wrapper function, which does the testing, invisible to the script being tested. That reduces the possibility where addition of a wrapper function inadvertantly causes a bug (that only manifests itself while running under the test-suite, making it harder to find), or causes a test to fail that wouldn't otherwise fail.
Does that clarify things?
Cheers,
|
|---|