--- Kirrily Robert <[EMAIL PROTECTED]> wrote:

> Does anyone here understand "fixtures" as a testing concept, and could
> they please explain it to me in a Perlish way?    
> 
> At least half of what I've heard described is what I usually achieve
> with a t/data/ directory, and another half is what I'd do by writing a
> specialized Test::Builder-based module.

A test fixture establishes a "known state" of a system.  For example, when
running with Test::Class, you can use "setup" and "teardown" methods which
run before and after every test to load test data in a  database, set up temp
files, or do anything necessary to start a known, stable state and later do
transaction rollbacks, clean up temp files and so on.

One of the reasons randomizing test runs is important is because they can
shake out bugs in the code when you have strange ordering dependencies, fail
to clean up temp files, alter global state, etc.  Test fixtures can make
finding such code errors even more reliable because they guarantee (to the
extent that they're not buggy) that every set of tests which runs has, if you
will, the same starting point.

Cheers,
Ovid

--

Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/

Reply via email to