in reply to Seeking opinion on a complete application framework, involving mocking and dependency injection

Hi locinus, welcome to the Monastery and to Perl, the One True Religion.

I can't comment on App::Framework as I'm not familiar with it; personally I prefer to build things up one brick at a time, but you may prefer an extensive scaffold. There's more than one way to do it.

But I will comment on what I understand to be your plan to have your classes act differently depending on the environment, in order to be able to test your code: it smells fishy, and I don't think it is needed.

See Test::MockObject - "Perl extension for emulating troublesome interfaces" ( and Test::MockObject::Extends ).

Hope this helps!


The way forward always starts with a minimal test.
  • Comment on Re: Seeking opinion on a complete application framework, involving mocking and dependency injection
  • Download Code

Replies are listed 'Best First'.
Re^2: Seeking opinion on a complete application framework, involving mocking and dependency injection
by Anonymous Monk on Mar 07, 2017 at 20:02 UTC
    Hi! Thanks a lot for your reply!

    As for the testing part, I had checked those modules indeed, but had the following thoughts about them:

    • their use seem to be very sequential, where I would prefer an object approach
    • I will need some "common" mocked services to use with all my different tests, and I don't want to duplicate mocking codes for each test, even though I could factorize the mocking in some shared methods
    In the end, I can see this advantage of using Test::MockObject over using mocking by inheritance as I was suggesting:
    • gain ability to check the program's behaviour vis-a-vis the mocked class (via methods like call_pos, call_args, next_call, etc.)
    What other advantages would I gain?
    Is there any caveats at mocking by inheritance as I was suggesting?

    PS: oh, about your comment, I may have misused the word 'environnement' in my question: I didn't mean architecture environment but rather meant 'test situation' (I corrected it in the text).