in reply to How to make a module aware it is being tested?

Sprinkle if (exists $INC{'Test/More.pm'}) (or whatever test module you are using) tests through your code as required.

That doesn't tell you if the code was actually called in a test context, but it does tell you if the test environment is loaded.


Perl is environmentally friendly - it saves trees

Replies are listed 'Best First'.
Re^2: How to make a module aware it is being tested?
by Roy Johnson (Monsignor) on Nov 01, 2007 at 22:34 UTC
    Seems like it would be a little more straightforward to test for one of the testing package's variables, like
    if ($Test::VERSION)

    Caution: Contents may have been coded under pressure.