The 2001 Perl Advent Calendar
[about] | [archives] | [contact] | [home]

On the 10th day of Advent my True Language brought to me..
Test::More

Now this is a module that I use every single day. Pretty much all I do at work (and when I'm coding at home) is write POD, write the tests (using Test::More) for that POD, and then try and get the tests to pass those tests. Wash, rinse, repeat.

Test::More is great and is such an improvement over Test.pm. As well as providing a mechanism for deciding if tests have passed or failed Test::More allows the testing harness to understand what you were expecting and to have some idea of what the test for. This means that Test::More can be used in development in order to work out what your program is doing wrong (rather than it's just doing something wrong.) It's the difference between knowing that your car is working or broke, or knowing that your car's tire is flat and you probably need to inflate it.

One example of this is the introduction of names for tests. You name the tests, and when one fails you can find it easily in your code and have a hope of working out what's actually wrong. Another simple, but really useful addition is the is and like methods that allow you to tell the test routine what you're expecting out and get it to work out if it's true - and more importantly print out proper debug information if it's not.

Test::More doesn't really give you anymore power than Test, but it does allow you to quickly craft test suites that behave properly and print out proper information when things go wrong. It puts the laziness back into test writing.

  • Test::Simple - simplier version
  • Test::Tutorial - a guide to testing