develooper Front page | perl.perl5.porters | Postings from February 2003

Test::More not warning on BEGIN{use_ok(...)} without a plan

Thread Next
From:
sthoenna
Date:
February 5, 2003 15:00
Subject:
Test::More not warning on BEGIN{use_ok(...)} without a plan
Message ID:
TJZQ+gzkgqyW092yn@efn.org
When you do something like:
====================
use strict;

use Test::More;

BEGIN
{
    eval { require DateTime };
    if ($@)
    {
        plan skip_all => "Cannot run tests before DateTime.pm is installed.";
        exit;
    }
}

plan tests => 1;
BEGIN
{
    use_ok('DateTime::TimeZone');
}
====================

The use_ok erroneously happens before the plan() call, but no warning is
given.  Compare:

$perl -MTest::More -wle'plan tests=>1; BEGIN{ok(0)}'
You tried to run a test without a plan!  Gotta have a plan. at blib/lib/Test/Mor
e.pm line 279
BEGIN failed--compilation aborted at -e line 2.
# Looks like your test died before it could output anything.

and:

$perl -MTest::More -wle'plan tests=>1; BEGIN{use_ok("Nosuch")}'
1..1
# No tests run!

Tested on 0.48_01.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About