Trapping exit AND using mocked objects?by LANTI (Sexton)
|on May 07, 2010 at 08:25 UTC||Need Help??|
LANTI has asked for the
wisdom of the Perl Monks concerning the following question:
Hi, I am writing a script for checking a filer. In order to test the script, I need predictable results and therefore use Test::MockObject to mock the answers from the server inside of the test-script. To have this mocked module being used by the tested script, I eval the tested-script, after reading it in by use of File::Slurp.
Bellow some code, the tested script is wrapped in a sub for simplicity.
Any idea how I can trap the exit 111 and still have the code executed in the lexical context of the test-script (or get the mocked NaServer instead of the one, used by the tested-script)?
Just to make things clear: The real script I want to test, has the use NaServer line not commented out, but since the NaServer Module is already loaded in the test-situation its not used again.