Subject: | dying in setup does not skip rest of test |
I have encountered somewhat surprising behavior in Test::Class which
reflects a problem with either my understanding of the intended API or
the way Test::Class copes with exceptions out of setup methods.
My expectation was that dying out of a setup method should abort the
rest of the test, so that the attached script would report two failures.
Instead, dying out of the setup method simply aborts the rest of that
particular method, without effect on the method on whose behalf the
setup method was being called.
This surprises me, and I think the correct fix is to abort the test
entire as failed -- the reasoning being that setup methods establish the
environment necessary to run the tests at all. An update to the
documentation would similarly alleviate my surprise, but seems to me to
be an inferior choice. Such an update should possibly suggest a
mechanism for skipping exactly the test method on whose behalf setup was
called.
Subject: | undead-tests.pl |
#!/usr/bin/perl
use strict;
use warnings;
package FooTest;
use base 'Test::Class';
use Test::More;
sub death : Test(setup) {
die();
}
sub must_not_run : Test(1) {
pass();
}
package main;
Test::Class->runtests();