home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Learning Perl Objects, References & ModulesLearning Perl Objects, References & ModulesSearch this book

14.5. More Complex Tests (Multiple Test Scripts)

Initially, the h2xs program gives you a single testing file, t/1.t.[105] You can stick all your tests into this file, but it generally makes more sense to break the tests into logical groups.

[105]As of Perl 5.8, that is. Earlier versions create a test.pl file, which is still run from a test harness during make test, but the output wasn't captured in the same way.

The easiest way to add additional tests is to create t/2.t. That's it—just bump the 1 to a 2. You don't need to change anything in the Makefile.PL or in the test harness: the file is noticed and executed automatically.

You can keep adding files until you get to 9.t, but once you add 10.t, you might notice that it gets executed between 1.t and 2.t. Why? Because the tests are always executed in sorted order. This is a good thing because it lets you ensure that the most fundamental tests are executed before the more exotic tests, simply by controlling the names.

Many people choose to rename the files to reflect a specific ordering and purpose by using names like 01-core.t, 02-basic.t, 03-advanced.t, 04-saving.t, and so on. The first two digits control the testing order, while the rest of the name gives a hint about the general area of testing. Whatever plan you decide to use, stick with it, document it if necessary, and remember that the default order is controlled by the name.



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.