14.4 Conditional TestsIf you write tests directly from the specification before you've written the code, the tests are expected to fail. You can include some of your tests inside a TODO block to include them for test count but denote them as unavailable at the same time. For example, suppose you haven't taught your horses how to talk yet: use Test::More 'no_plan'; Here, the test is inside a TODO block, setting a package $TODO variable with the reason why the items are unfinished:[13][13] TODO tests require Test::Harness Version 2.0 or later, which comes with Perl 5.8, but in earlier releases, they have to be installed from the CPAN . ok 1 - use Horse; Note that the TODO test counts toward the total number of tests. Also note that the message about why the test is a TODO test is displayed as a comment. The comment has a special form, noted by the test harness, so you will see it during a make test run.You can have multiple TODO tests in a given block, but only one reason per block, so it's best to group things that are related but use different blocks for different reasons. |
•
Table of Contents
•
Index
•
Reviews
•
Reader Reviews
•
Errata
Learning Perl Objects, References & Modules
By
Randal L. Schwartz