in reply to How to structure tests that span several modules
source bin lib t data
The lib directory (and below) contains the source files (for My::Module::Name in My/Module/Name.pm).
The t directory contains all the test files, one for each class (e.g. My-Module-Name.t). Sometimes there are extra files for some classes if some aspects of it need more tests (e.g. My-Module-Name-convert.t). I don't care about the order of tests being run; if something breaks, it's usually easy to figure out the root cause of the breakage.
The t/data directory contains data used by the tests.
Basic classes are easily tested by themselves. Other classes have dependencies, and then it becomes necessary to set up an environment for them to work. I do this in each file that needs it. Sometimes it becomes very repetitive, and it may be a good idea to refactor the setup test code into a class (e.g. SetupFoo.pm) which I put in the t directory and use from the .t files.
For complicated chains of depdent classes or external resources like web server access or time, I find it useful to fake it with Test::MockObject. WWW::Mechanize::Cached is also useful to fake web sites.
Well, that's how I do it.
/J
|
|---|