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

I'm working on a module that requires various bits of info in order to test itthoroughly (e.g.database/host/user/pass for DBI).

I've been looking at how different modules handle it. The MySQL module, for example, prompts for information and then writes a config file. In contrast, Tie::DBI relies on environment variables and simply skips the tests if it's unable to connect.

Which approach do you prefer? I'm hesitant to just rely on environment variables and not warn the user that I'm planning to read/write files, tables, etc.

Can you recommend any modules with complex tests that you think handle it particularly well?

Replies are listed 'Best First'.
Re: Complex module testing
by knight (Friar) on May 04, 2001 at 17:47 UTC
    I prefer anything that helps automate the tests, so interactive prompts are a drawback. They can still be handy as a fall back when there isn't any environment variable or config file available, but don't force someone to type in additional info every time the tests are run.

    The Test::Cmd module provides a model for reading and writing files for testing. It's based on the testing conventions for the Aegis change management system: all files get created in one or more temporary directories; you don't rely on being in any special directory or having any special config files in place for the tests to run. Test::Cmd provides a portable API for managing this and cleaning up afterwards.

    If you don't find Test::Cmd useful for your purposes, you might get some ideas from looking at the tests for the module, which do this same sort of test-file management without using Test::Cmd itself.