http://www.perlmonks.org?node_id=289527


in reply to Re: Optional modules for tests?
in thread Optional modules for tests?

Thanks for the response.

I've been experimenting with this and have minimized my test code to the following:

use Test::More tests => 1; SKIP: { eval{ require Data::Dummy }; skip "Data::Dummy not installed", 2 if $@; ok( 1 ); }
This works fine when the required module is present, but in the case of a non-existant module (such as with the above Data::Dummy), the following is reported:
C:\>nmake test Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. C:\Perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_harn +ess(0, 'blib\lib', 'blib\arch')" t\test.t t\test....# Looks like you planned 1 tests but ran 1 extra. t\test....dubious Test returned status 1 (wstat 256, 0x100) DIED. FAILED test Failed 0/1 tests, 100.00% okay (less 2 skipped tests: -1 okay, + -100.00%) Failed Test Stat Wstat Total Fail Failed List of Failed ---------------------------------------------------------------------- +--------- t\test.t 1 256 1 0 0.00% 2 subtests skipped. Failed 1/1 test scripts, 0.00% okay. -1/1 subtests failed, 200.00% oka +y. NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code + '0x2' Stop.
I don't understand why this would complain of skipping two subtests, nor why it says that I planned 1 test but ran 1 extra. Is this what normally happens when tests are skipped?