Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: testing code

by geekgrrl (Pilgrim)
on May 05, 2004 at 22:57 UTC ( [id://350946]=note: print w/replies, xml ) Need Help??


in reply to Re: testing code
in thread testing code

ooh.. cool new modules to try. thanks!

I definitely want to try out Test::Exception - I'm often using eval blocks. And Devel::Cover looks quite interesting. I haven't thought about using coverage reports before.

One of these days I know I should graduate up to Test::More, but i've been holding off so far...it's that laziness factor, i guess, and Test::Simple is just so...simple and easy.

Update: I've switched my eval blocks over to use Test::Exception routines like throws_ok and lives_ok. It makes the code much more readable, and saves me some typing, too.

Replies are listed 'Best First'.
Re: Re: Re: testing code
by leriksen (Curate) on May 06, 2004 at 02:51 UTC
    We use Test::More all the time.

    Every <module>.t we write has a corresponding t/<module>.t test file written for it.

    I've included a real Makefile.PL from one of our projects, and a sample Test::More template .t file.

    You should also read the ExtUtils::MakeMaker doco for more sophisticated ways of calling make test

    # Makefile.PL use ExtUtils::MakeMaker; WriteMakefile( NAME => 'txu_bims', VERSION_FROM => 'VERSION.pm', test => {TESTS => './TXU/BIMS/t/*.t ./TXU/t/*.t' +}, # how to pass multiple test paths PMLIBDIRS => ['./TXU/BIMS', './TXU'], PREREQ_PM => { Log::Log4perl => 0.36, }, );
    # template Module/Under/t/Test.t #!/usr/bin/perl -w use strict; use Test::More qw(no_plan); use Module::Under::Test; # test go here my $obj = Module::Under::Test->new(); isa_ok($obj, 'Module::Under::Test'); is($obj->method(), 'expected output', 'standard test'); is_deeply($obj->meth_retn_ref(), {complex => {structure => ['here']}}, + 'method returns ref to complex structure');

    After this, its as simple as ...

    perl Makefile.PL make test

    More complex examples of calling make test are ...

    • make test TEST_VERBOSE=1
      for more detailed information on test execution
    • make testdb TEST_FILE=path/to/script.t TESTDB_SW=-d:ptkdb
      to run just path/to/script.t under the GUI debugger ptkdb (which is a great debugger

    *UPDATE* - proxy dropped out half way through uploading this - added the point list

    +++++++++++++++++
    #!/usr/bin/perl
    use warnings;use strict;use brain;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://350946]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2024-03-28 15:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found