jk2addict has asked for the wisdom of the Perl Monks concerning the following question:

This is quite a loaded question so be gentle. :-)

I'm entertaining the idea of writing Test::CPANTS. During the development process, I want to be able to test my kwalitee rating (keeping it at 16) every time I get ready to release a new version of a module.

I've taken a look and Modules::CPANTS::Generator. Most of it looks reusable (like the individual test modules); but a good portion of it ::Generator seems to be based around the idea the I'm going to download a dist and use that. In the case of a Test::CPANTS, I'm really trying to work with the local lib/blib part of the dist to be tested.

This brings my to my question. Is it ok to use Test::MockObject for good (test.pl, t/*.t) AND evil; fooling Modules::CPANTS::Generator into using my local hacks to get it and CPANPLUS to not download things, but intead to use the local dist directory and a non-existant .tar.gz dist?

Ultimately it would be better to tweak Modules::CPANTS::Generator to work the way it is needed, but wheres the fun in that? :-)

  • Comment on Using Test::MockObject For Good And Evil

Replies are listed 'Best First'.
Re: Using Test::MockObject For Good And Evil
by chromatic (Archbishop) on Mar 16, 2005 at 22:39 UTC

    You could certainly do this, but you're probably better off building your own interface-compatible modules instead.

    The key is in putting an AUTOLOAD in your own object and having it report the unimplemented methods. Then go through and implement them.

      That's where I get a little fuzzy. I'd like to use as much of the CPANTS modules as possible. I think I can get away with using ::CPAN, ::Files, ::FindModules, ::Pod, ::Prereq, ::Unpack, and ::Uses without to much hackery jigery pokery. I could reimpliment my own versions of these test, but I really don't want too, especially if they change over time.

      The base module on the other hand is a different story.