Perl Testing: A Developer's Notebook
Ian Langworth and chromatic
The examples in the book are available for downloading from the O'Reilly website at http://examples.oreilly.com/perltestingadn/.
The book's website is located at http://www.oreilly.com/catalog/perltestingadn/.
From the back cover...
Can you think of a sexier topic in software development than software testing? Well, besides game programming, 3D graphics, audio, high performance clustering, cool websites... Okay, so maybe software testing is low on the list. That's unfortunate because good software testing increases productivity, improves designs, raises quality, eases maintenance burdens, and helps you satisfy customers, coworkers and managers.
First off, the main audience for this book seems to be developers who are working with or who will be working with medium to large Perl projects. For this group of people, this book is a great resource on how to use tests to improve your Perl coding output, both in quality (less bugs), and quantity (less time tracking bugs). Not to say that everyone who reads the book won't benefit from reading it, however, people who don't write more than a page or two of Perl code may not care enough to invest the time to learn how to write tests for a script that does only one or two things in the first place.
That being said, I (the reviewer) definitely fall into the first category (lots of Perl code to wrangle), and found the examples given in the book realistic and applicable to the code that I am currently working on, as well as giving me ideas for future projects and how to structure these future projects to include testing from the beginning of the project instead of tacking code testing onto the project as an afterthought midway through or at the end of the project.
If you're not familiar with the O'Reilly "Developer's Notebook" series of books, the book is laid out in a way that resembles how people might take notes in an "engineering lab book", as if they were learning about Perl testing in a classroom environment. The book will give an example problem, then solve the problem via an example Perl script, and then walk through each block of code in the Perl script and explain what that block does. At the end of most of the walkthroughs, additional ways of solving the problem are also discussed. More complex problems may also be given, which leads the readers into the next question and answer section of that chapter. By formatting the book as a set of increasingly complex questions and answers, it helps make the more complex concepts about Perl testing easier to understand when the examples are followed from the beginning of the chapter to the end. The margins of the pages sometimes contain "handwritten" notes from the authors to the reader that give hints or tips specific to the subject matter that is currently being discussed in that section of the book.
Chapters In Brief
Chapter One discusses installing the Perl testing modules, running simple tests, and interpreting the results of those tests.
Chapter Two discusses how to skip tests, or mark tests as TODO, so that you can skip out of tests you know will not be able to run, or write stubs for tests that will be filled out at some point in the future.
Chapter Three covers organizing tests, verifying that your tests cover the code you are running tests against, testing across a network, and automating tests.
Chapter Four talks about the things that might be done should you decide to distribute your Perl code to other users. Validating Perl POD documentation, testing entire distributions of code, bundling tests with modules, and collecting test results are covered.
Chapter Five discusses testing things that may not normally be testable, including Perl built-ins, modules, objects, live Perl code and overloading Perl operators.
Chapter Six talks about testing with databases, including using temporary databases and mocking databases in order to test your code.
Chapter Seven is all about testing websites. Since a lot of people write CGI code using Perl, being able to test that code can be valuable in making sure that your website is secure and is bug-free. Backend and frontend testing, recording and playing back CGI sessions, testing HTML validity, running an Apache server specific for testing CGI code, and using Apache-Test for testing are all discussed.
Chapter Eight is all about Test::Class, the object-oriented Perl testing framework. Using Test::Class, you create Perl objects that test your existing functions or objects. By placing all of your testing objects inside of Perl classes, you can reuse the testing classes for the same project or for different projects that you build.
The last chapter, Chapter Nine, goes over how to use Perl testing to test non-Perl things such as external binaries and shared libraries.
Please direct any questions, comments or complaints about this site to