Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Unit Testing

by ait (Hermit)
on Jul 29, 2008 at 17:44 UTC ( [id://700879]=perlquestion: print w/replies, xml ) Need Help??

ait has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

More than a question this is a kind of poll to see what is being used, recommendations tendencies, etc. regarding unit testing in Perl.
I would like to know who uses what and why. For example comparisons between PerlUnit and Test::Class . I am currently starting with PerlUnit because of a customer request but would like to hear opinions on the different Unit testing modules and strategies.
Thanks,
Alejandro Imass

Replies are listed 'Best First'.
Re: Unit Testing
by EvanK (Chaplain) on Jul 29, 2008 at 18:26 UTC
    I've only ever used the likes of Test::Class and Test::More for Perl unit tests. Mostly because it's a de facto community standard for modules that go up on cpan.

    I have used JUnit derivatives in other languages, but can't attest to the quality either way of PerlUnit.

    __________
    Systems development is like banging your head against a wall...
    It's usually very painful, but if you're persistent, you'll get through it.

Re: Unit Testing
by duckyd (Hermit) on Jul 29, 2008 at 18:30 UTC
    I personally like Test-Class a lot. It integrates well with the very standard Test::More and friends, and I think is easier for people used to just .t style tests to migrate to.
Re: Unit Testing
by jdrago_999 (Hermit) on Jul 30, 2008 at 18:46 UTC
    I recommend going with the more standard (for Perl anyway) Test::More way of doing things.

    While you're at it, take a look at Devel::Cover for code-coverage and Devel::NYTProf for profiling. Both will dump navigable HTML files that show you visually what is happening inside your code during execution. Very informative.
Re: Unit Testing
by Ovid (Cardinal) on Aug 02, 2008 at 14:42 UTC

    First, a bit of background so you know where I'm coming from: I'm the original author of the new Test::Harness module, I'm heavily involved in the Perl-QA community, I teach people testing, I have several testing modules on the CPAN and have written and published the results of Test Survey Results. In short, I know this area very, very well, so I hope you'll understand that I don't say "don't use PerlUnit" out of complete ignorance.

    PerlUnit was an interesting project, but it's a dead one. Also, it does not integrate with the standard Perl testing tools. As a result, the wealth of powerful testing modules in Perl are pretty much not an option for you. Out of over 15,000 distributions on the CPAN, it appears that only 14 of them use PerlUnit (its front-end is named Test-Unit) and half of those are for one author on one set of related modules.

    As for what people are actually using, I ran an analysis of the testing software used in CPAN modules and the top ten (out of 287) testing modules identified were:

    Module Number of test programs Test::More 44461 Test 8937 Test::Exception 1379 Test::Simple 731 Test::Base 316 Test::Builder::Tester 193 Test::NoWarnings 174 Test::Differences 146 Test::MockObject 139 Test::Deep 127

    Aside from Test, a legacy module used by older code, the standard Test::Harness based testing modules (Test::More, Test::Exception, Test::Differences, etc.) will be far more useful for you and new testing tools are coming out all of the time for it.

    Of course, if the customer is requesting PerlUnit because they rely heavily on it, you may be stuck, but try to avoid it. If it's being considered because of its xUnit philosophy, I recommend you check out Test::Class. It's a great module and I use it all the time.

    Cheers,
    Ovid

    New address of my CGI Course.

      Wow. Thank you, very, very much Ovid!
Re: Unit Testing
by robot_tourist (Hermit) on Jul 30, 2008 at 09:55 UTC

    I have dabbled with Test::More and liked the fact that when I was using JEdit and ran the tests via JEdit's Console plugin I could see red or green on fail or pass.

    How can you feel when you're made of steel? I am made of steel. I am the Robot Tourist.
    Robot Tourist, by Ten Benson

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://700879]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-26 01:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found