Subject: | Test::Class can't handle exceptions in startup method |
This code raises an exception in the startup metod:
---------< Start Test.pm >---------
#!/usr/bin/env perl
package Test;
use strict;
use warnings;
use base qw(Test::Class);
use Test::More;
sub startup : Test(startup) {
die;
}
sub test : Tests {
ok(1, 'test that should be skipped because of the exception in startup');
}
Test::Class->runtests;
1;
---------< End Test.pm >---------
It produces this output:
---------< Start output >---------
Use of uninitialized value in string ne at /usr/lib/perl5/site_perl/5.8.3/Test/Class.pm line 192.
Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/site_perl/5.8.3/Test/Class.pm line 192.
not ok 1 - startup (for test method '') died (Died at ./Test.pm line 9.)
# Failed test (./Test.pm at line 16)
ok 2 - test that should be skipped because of the exception in startup
1..2
# Looks like you failed 1 test of 2.
---------< End output >---------
Test:Class can't handle the exception as seen above (the uninitialized values). I also think that all the tests in the module should be skipped (or failed) if the startup methods raises an exception. The reason for raising an exception in the startup method could be a failure in setting up the testing environment, and then no tests can be run at all.