in reply to Strategy for conditional logging in tests

Howdy!

If you put your subroutine in a .pm file, you can diddle the logging to appropriate levels in the .t and .pl files instead of having to do conditional hacks based on caller().

yours,
Michael
  • Comment on Re: Strategy for conditional logging in tests

Replies are listed 'Best First'.
Re^2: Strategy for conditional logging in tests
by andreas1234567 (Vicar) on Apr 01, 2008 at 16:38 UTC
    I don't see that making it a module would make a difference. Please elaborate.
    --
    Andreas
      I agree that having your code as a module or not does not make a big difference here, but you should be able to "diddle the logging to appropriate levels in the .t". Is it not possible to turn off logging from the test script for your negative tests, and then turn it back on for the others?
        Well, I could always add functionality to toggle logging on or off and invoke it during tests, e.g. something simple like this:
        sub log_toggle { ($_[0]) ? Log::Log4perl->appender_thresholds_adjust(7) : Log::Log4perl->appender_thresholds_adjust(-7); }
        However I think it's inelegant to add functionality to the script that is going to be used during testing only. I would rather that the test script did that alone.