in reply to load a module or another: Dumper or dd

I hope to have understood what you're trying to achieve: if you want to test that code, you should re-factor the use Data::Dump; 1; inside a sub{} and then make that explode at will by mocking. In this case Test::MockObject would help a lot with testing, but seen that you're trying to minimize required deps you have to decide if the whole thing is still worth the extra mocking work "by hand".

Replies are listed 'Best First'.
Re^2: load a module or another: Dumper or dd
by stevieb (Canon) on Jan 09, 2019 at 22:32 UTC

    My understanding is that OP wants to use Data::Dump if it's found on the system, and Data::Dumper if it isn't. I don't believe that this is a test situation that could be mocked out.

      Yes that part (the fact that the OP wants to optionally use a module if present) is quite clear. What it is not is why he wants to mock the absence of that particular module in its current setup/environment!

      The only thing which I thought would make sense is for testing that optionally loading code logic: I assumed that the problem was testing the module absence, which it can be done having a subroutine which mocks the loading of a fantasy module, e.g.: sub{ use Supercalifragilistichespiralidoso; 1 }