On 2/13/07, Kirrily Robert <[EMAIL PROTECTED]> wrote:
can someone explain it to me *in a perlish way*.
I think of fixtures as code that helps make testing data driven. I haven't
used Test::Class (though I probably should sometime), but instead, I
refactor my unit tests into the simplest thing that would work.
I typically refactor unit tests first into functions at the bottom of the
t/*.t file, then to a t/TestUtil.pm (or somesuch), and then into a test
class if necessary. Also, I also usually whip up mock libraries that
fixture code would use, and keep it in t/lib, and then 'use lib "t/lib"' in
my unit test files.
My favourite recent example was where I wrote unit tests for a search
feature, and I quickly wrote 100-ish different tests, based off of story
notes:
Wildcard_tests: {
search_ok( 'monkey', qr/Found 3 results/, ['Foo', 'Bar', 'Baz'] );
}
sub search_ok {
# initialize search module
# seed search results
# perform search
# perform test assertions
}
Something like that.
I think this is also fixture-ish, as I'm making it really easy to test
additional lightbulbs.
Cheers,
Luke