Skip to content
schwern edited this page Feb 6, 2011 · 2 revisions

Some core principles guiding the development of Test::Builder and Test::More.

It Has To Work

The overriding design principle is that the tests have to work. This overrides every other principle.

Universally Applicable

Because Test::Builder underlies all the test modules, Test::Builder has to work for every environment and situation where Perl will work.

Note that t/test.pl from the Perl core frees us from having to worry about bootstrapping Perl itself.

Non-Interference

Code should work just the same in a test script as in a normal script.

For example, you might be tempted to write a test routine which uses the & prototype to accept a "block" that's really a subroutine reference.

sub run (&) {
    my $code = shift;
    $code->();
}

run {
    ...test code...
};

The fact that it's not really a block can be seen by anything which uses caller(). Consider testing Carp. To complete the encapsulation you have to trick caller() by using something like Sub::Uplevel.