Skip Menu |
 

This queue is for tickets about the Test-Class CPAN distribution.

Report information
The Basics
Id: 64268
Status: resolved
Priority: 0/
Queue: Test-Class

People
Owner: Nobody in particular
Requestors: DARCH [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.36
Fixed in: (no value)



Subject: dying in setup does not skip rest of test
Download (untitled) / with headers
text/plain 941b
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
Download undead-tests.pl
text/x-perl 226b
#!/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();
Download (untitled) / with headers
text/plain 1.2k
Hi, On Mon Dec 27 15:44:05 2010, DARCH wrote: Show quoted text
> 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.
[snip] Agreed. Now if the setup method of a test dies all of the remaining setup, test & shutdown are also skipped. This version is now in git at https://github.com/adrianh/test-class - and wil be released in the next couple of days. Thank you for the bug report :-) Cheers, Adrian Show quoted text
> > 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.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.