Skip Menu |

This queue is for tickets about the Test-Mock-Simple CPAN distribution.

Report information
The Basics
Id: 104417
Status: rejected
Priority: 0/
Queue: Test-Mock-Simple

People
Owner: Nobody in particular
Requestors: eallenvii [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Does not play well with exporter
Date: Wed, 13 May 2015 15:54:50 -0700
To: <bug-Test-Mock-Simple [...] rt.cpan.org>
From: Ethan Allen <eallenvii [...] gmail.com>
Was attempting to mock a CPAN module, Time::HiRes where I was using exporter to get gettimeofday() to return a known calculated value. From the test harness I could call gettimeofday and get my value. From the module I was testing when it called gettimeofday it would return the real value. I surmise that while I mocked Time::HiRes::gettimeofday, I didn't mock MyModule::gettimeofday which is where exporter stuck it and what my test harness was calling. -e
Exporter moves method names into the 'main' namespace. It is anathema to Test::Mock::Simple. To test exported metods move them into a method of an object and mock that new 'helper' method. On a person note: Exporting is a sin of previous Perl. Exporting only leads to confusion as to where a method is defined - it should be avoided at all costs.