-
Notifications
You must be signed in to change notification settings - Fork 88
Principles
Some core principles guiding the development of Test::Builder and Test::More.
The overriding design principle is that the tests have to work. This overrides every other principle.
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.
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
.