ADBRITE ads links
You are here: CodeIdol.com > Perl > Intermediate Perl > Essential Testing
Intermediate Perl
| 17.1. More Tests Mean Better Code
Why should we test during development? The short answer is that we find out about problems sooner and tests force us to program in much smaller chunks (since they are easier to test), which is gener...
|
|
| 17.2. A Simple Test Script
Before we go on, let's write some Perl code. We just told you about creating the tests before you write the code, so maybe we should follow our own advice. We'll get to the details later, but for now we start with ...
|
|
| 17.3. The Art of Testing
Good tests also give small examples of what we meant in our documentation. It's another way to express the same thing, and some people may like one way over the other.[*] Good tests also give confidence to the user that...
|
|
| 17.4. The Test Harness
We usually invoke tests, either as the developer or the user, by using make test
. The Makefile uses the Test::Harness module to run the tests, watch the output, and report the results.
Tests live in files ...
|
|
| 17.5. Writing Tests with Test::More
The Test::More[*] module comes with the standard Perl distribution starting with Perl 5.8, and it's available on CPAN if we need to install it on earlier Perl versions. It works all the way back to p...
|
|
| 17.6. Testing Object-Oriented Features
For object-oriented modules
, we want to ensure that we get back an object when we call the constructor. For this, isa_ok( ) and can_ok( ) are good interface tests:
use Test:...
|
|
| 17.7. A Testing To-Do List
When we write tests before we write the code, the tests will initially fail. We might even add new features that temporarily fail while we are developing. There are several situations where we realize a test is ...
|
|
| 17.8. Skipping Tests
In some cases, we want to skip tests. For instance, some of our features may only work for a particular version of Perl, a particular operating system, or only when optional modules are available. To skip tests, we do...
|
|
| 17.9. More Complex Tests (Multiple Test Scripts)
Initially, the h2xs program[*] gave us a single testing file, t/1.t.[] We can stick all our tests into this file, but it generally makes more sense to break the tests into logical groups in separate...
|
|
| 17.10. Exercise
You can find the answer to this exercise in "Answer for Chapter 17" in the Appendix.
17.10.1. Exercise [60 min]
Write a module distribution, starting from the tests first.
Your goal is to create a module My::List::Uti...
|
|
You are here: CodeIdol.com > Perl > Intermediate Perl > Essential Testing
|
|
Related tags
Popular Categories
Unix books and guides
AJAX popular information
C# language guides
Windows books and cookbooks
.......
|
|