in reply to Testing at the right granularity

As a consequence, the number of tests is likely to explode,

On the other side, I feel like I'm cheating doing all these repetitive tests, and having lots of "ok..." where I should really have one,

It sounds like you've adopted a mindset that looks at the raw numbers at the end of the run, instead of looking at the actual testing.

Having a large number of tests doesn't mean anything.

There's no "cheating" if the number of tests goes up.

There's no sin in re-testing the same thing in multiple files. For example, there's nothing wrong, and indeed everything right, with checking the result of every single constructor call, as in

my $foo = Foo::Bar->new(); isa_ok( $foo, 'Foo::Bar' );
in every single file. For that matter, there's nothing wrong, and indeed everything right, with check the result for each line of text:
while ( my $line = <> ) { my $foo = Foo::Bar->parse( $line ); isa_ok( $foo, 'Foo::Bar' ); ... }
Don't worry about the test numbers. Keep throwing tests at it.

xoxo,
Andy

Replies are listed 'Best First'.
Re^2: Testing at the right granularity
by polettix (Vicar) on Apr 20, 2005 at 20:49 UTC
    My fear in the original post derived from a couple of sentences I read. One was inside a module's documentation, talking about the testing in a similar module ("there are only 5 tests..."), the other stating that "a few dozen of tests should suffice".

    Unluckly I cannot produce references, but these sentences stayed in my mind when I came to testing, and having a final count of around 200 for something that wasn't actually that great made me think that I was kinda cheating.

    Anyway, I like the attitude you suggest: I'll not worry about these foolish things and keep going on.

    Flavio (perl -e "print(scalar(reverse('ti.xittelop@oivalf')))")

    Don't fool yourself.