in reply to Re^2: How to use a private version of a published module?
in thread How to use a private version of a published module?
My test code does not call Rest::Client, which is what I need to mock. Rest::Client is used by the module under test, not the test code.
It does not matter where in the chain of calls REST::Client is used. It is the subs within REST::Client which are mocked. You do not need to change your module at all. Your test script sets up the mocking, instantiates an object of your class and when your test script calls some method of your class which, somewhere down the line, calls a method on REST::Client, that is what is magically mocked by Test::MockModule.
Trust me on this, mocking is definitely the way to go here. You don't have to use Test::MockModule - there are plenty of other good mocking modules. The very fact that there are many of them should hopefully indicate to you how prevalent mocking is as a valid test tool and to get around precisely the problem you are presently having.
🦛
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How to use a private version of a published module?
by MARKWIN (Novice) on Jun 19, 2021 at 19:22 UTC |