develooper Front page | perl.perl5.porters | Postings from June 2001

Re: on testing

Thread Previous | Thread Next
From:
schwern
Date:
June 4, 2001 08:56
Subject:
Re: on testing
Message ID:
20010604115646.C29982@magnonel.guild.net
On Sun, Jun 03, 2001 at 03:43:47AM +0100, Hugo wrote:
> I'd like to encourage all test writers to take this issue into account,
> and I'd particularly like to see this issue accounted for by the Test
> module. I appreciate that it seems like an obvious improvement to save
> the test writer from having to add 1, but I suggest that it is a false
> economy.

One step ahead of you.  Have a look at Test::Simple and Test::More.
They introduce the idea of test names, short descriptions of each
test.  The numbers become little more than bookkeeping.

    use Test::Simple tests => 3;
    ok( $this eq 'that', 		'this is that' );
    ok( Some::Class->can('bar'),	'Some::Class->bar() exists');
    ok( @stuff,				'got some stuff');

produces

    1..3
    ok 1 - this is that
    ok 2 - Some::Class->bar() exists
    ok 3 - got some stuff

now you can stick a test in anywhere and find it quickly from its name.


Test::Simple is a candidate for the core once its interface has
solidified a bit more.



> The difficulty comes when you want to insert a new test in the
> logical place, which could involve renumbering all the subsequent
> tests. My suggestion for avoiding this is: don't; just add the new
> test at the end.

Please no, the test files will become an incomprehensible mess with no
rhyme or reason if we just start chucking things at the end.  Try to
keep similar tests grouped.



-- 
Michael G Schwern   <schwern@pobox.com>   http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <perl-qa@perl.org>       Kwalitee Is Job One

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About