Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Perl test module should I use?

There's Test::Simple, Test::More, Test::Builder (all part of the Test::Simple distribution), Test::Class, Test::Unit, Test::Moose...

I'm starting a new project using Moose—which module should I use for writing my tests?

like image 662
Drew Stephens Avatar asked Sep 11 '10 06:09

Drew Stephens


People also ask

What is CPAN module in Perl?

The Comprehensive Perl Archive Network (CPAN) is a repository of over 250,000 software modules and accompanying documentation for 39,000 distributions, written in the Perl programming language by over 12,000 contributors.

How do I create a test case in Perl?

1. Write Test Cases with Test::Simple. You can write test cases in perl using the perl Test::Simple module which has the basic functionality for testing. Before proceed to writing test case, first you need to plan the number of test cases and then the actual test cases.

How do I run a unit test in Perl?

Unit testing in Perl couldn't be easier. You run unit tests just like normal code (e.g., perl MYFILE ). There are just two functions you need to remember: is(EXPERIMENTAL_VALUE, EXPECTED_VALUE, OPTIONAL_MESSAGE)


1 Answers

You can eliminate Test::Builder from the list for a while. Test::Builder is the base module that other Test:: modules are built on. So until you want to start writing your own test modules you won't need it.

I'd also ignore Test::Simple. Test::More does all that Test::Simple does - and plenty more.

Test::Class is a nice way to write unit tests in a really object oriented way. I'd recommend it for complex OO-based systems.

Test::Moose is for testing various Moose-related features in your code. You say that you're using Moose so it might well be useful for you. It can be used in conjunction with Test::More.

So my recommendation would be to start with Test::More and Test::Moose. But also take a look at Test::Class to see if it fits with the way that you want to write tests.

Perl Testing: A Developers Notebook is a great introduction to this topic.

like image 62
Dave Cross Avatar answered Oct 03 '22 08:10

Dave Cross