Thanks all, especially Ovid who came closest to answering the actual
question, i.e. can someone explain it to me *in a perlish way*.  Ovid's
example used Test::Class's setup/teardown; would anyone else be able to
provide confirm that I'm making sense in the following
Test::Harness/Test::More style example:

1. Assume a test file t/foo.t
2. Assume a directory t/data (or t/fixtures if you will -- I just call
it data in my own tests).
3. Create a file t/data/foo.yml (or whatever data format) containing the
data needed by the tests in foo.t
4. At the beginning of foo.t, load data/foo.yml into whatever data
structure (memory, SQLite, real database, etc)
5. Run tests against foo.t
6. When foo.t exits, tear down the data created in step 4.

Yes?  In other words "fixtures" is just a jargony name for t/data/,
right?

And, is the above setup/teardown stuff right, or would you do it before
each individual test?  That would seem to be nearly nonsensical, but
then, I've seen stupider ideas.

My earlier comment about Test::Builder-based test modules was that some
of the fixtures stuff I've seen used repeated code chunks to go over the
contents of foo.yml, for instance doing validation runs against each
record, and it looked to me as if the Perlish way to do that is to write
a test module that provides record_is_valid() and related stuff.  As I
understand it now, this isn't actually part of "fixtures" conceptually,
it's just something that one might tend to see near fixtures.

K.

Reply via email to