in reply to Re: Testing at the right granularity
in thread Testing at the right granularity
To make an exageration, suppose I've some function result that I have to check against the string "ciao a tutti":
Now, I can take the direct path:my $result = function_under_test(); my $expected = "ciao a tutti";
But I can go much deeper:is($result, $expected, "strings are equal");
I repeat: this is an exageration, I'm not saying that I'm doing my tests this way. Nonetheless, I sometimes feel that maybe a more compact test (like the first) would do equally good as the bloated one.my @result = split //, $result; my @expected = split //, $expected; is(scalar(@result), scalar(@expected), "length match"); for (my $i = 0; $i < @expected; ++$i) { is($result[$i], $expected[$i], "$i-th char match"); }
Flavio (perl -e "print(scalar(reverse('ti.xittelop@oivalf')))")
Don't fool yourself.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Testing at the right granularity
by revdiablo (Prior) on Apr 19, 2005 at 18:15 UTC | |
|
Re^3: Testing at the right granularity
by tlm (Prior) on Apr 20, 2005 at 02:32 UTC | |
|
Re^3: Testing at the right granularity
by grinder (Bishop) on Apr 20, 2005 at 06:31 UTC |