Skip to Main Content
Beginning Perl
book

Beginning Perl

by Curtis Ovid Poe
September 2012
Beginner content levelBeginner
744 pages
15h 48m
English
Wrox
Content preview from Beginning Perl

Chapter 14

Testing

WHAT YOU WILL LEARN IN THIS CHAPTER:

  • Understanding basic tests
  • Learning the Test::More module in depth
  • Using different testing modules
  • Understanding xUnit style testing

WROX.COM CODE DOWNLOAD FOR THIS CHAPTER

The wrox.com code downloads for this chapter are found at http://www.wrox.com/remtitle.cgi?isbn=1118013847 on the Download Code tab. The code for this chapter is divided into the following major examples:

  • lib/TestMe.pm
  • t/testit.t.pm
  • lib/TestQuery.pm
  • t/query.t
  • lib/Person.pm
  • t/test_classes.t
  • t/test_classes.t
  • t/lib/TestsFor/Person.pm
  • lib/Customer.pm
  • t/lib/TestsFor/Customer.pm
  • lib/TV/Episode.pm

The author recently downloaded and built Perl version 5.15.9. All 521,047 tests passed. That’s right: Perl ships with more than a half-million tests. Not all of them are perfect, and sometimes they verify that a feature works the way it was written and not the way that was intended, but it’s still an incredible number. Few programming languages ship with more than a half-million tests. Testing your software is easy, and the Perl community is keen on testing. A few years ago, some people still argued against testing, but today professional Perl developers test more often than not.

BASIC TESTS

Consider the following line of code:

sub reciprocal { return 1 / shift }

Because the reciprocal of a number is 1 divided by that number, this looks like the canonical definition of a reciprocal. What could possibly go wrong?

When developers write tests, they often write a test ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Perl

Mastering Perl

brian d foy
Perl One-Liners

Perl One-Liners

Peteris Krumins
Learning Perl, 6th Edition

Learning Perl, 6th Edition

Randal L. Schwartz, brian d foy, Tom Phoenix
Programming the Perl DBI

Programming the Perl DBI

Tim Bunce, Alligator Descartes

Publisher Resources

ISBN: 9781118235638Purchase book