in reply to Do you use loops in your unit tests?
To answer the question in your title: yes.
The style of testing you describe, I'd call data-driven testing, and there's nothing wrong with it (I like it, actually), but your particular example is quite a sight to behold. For some slightly cleaner examples, see (in no particular order):
I'd like to offer you a rewritten copy of your own example, but I'm not sure I understand what it's doing. Maybe this:
plan 'tests' => scalar @Tests; foreach my $test (@Tests) { my $result = eval { Foo->new( $test->{params} ); 'ok' }; my $desc = $test->{desc} || 'test Foo->new'; is( $result, $test->{result}, $desc ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Do you use loops in your unit tests?
by Mutant (Priest) on Jan 04, 2008 at 21:47 UTC |