After having accumulated enough tests that running them all takes some real time, I looked at the Test::Class::Load
doc to find a tip for running individual test classes. It provides a manner to do this, but I must be missing something, because I can't make it work. Here's what I have:
My test directory:
drewfus:~/sandbox$ ls t/
lib/ perlcriticrc PerlCritic.t Unit.t
t/Unit.t
consists of the following:
use strict;
use warnings;
use Test::Class;
use Test::More 'no_plan';
use Test::Class::Load 't/lib';
Per the suggestion in the Test::Class::Load
doc, I have a base class for each of my test classes to inherit from, SG::TestBase
that lives at t/lib/SG/TestBase.pm
:
package SG::TestBase;
use strict;
use warnings;
use base 'Test::Class';
INIT { Test::Class->runtests }
1;
And finally, here is an example test class, SG::UtilsTest
at t/lib/SG/UtilsTest.pm
:
package SG::UtilsTest;
use strict;
use warnings;
use base 'SG::TestBase';
BEGIN { use_ok('SG::Utils') };
<etc>
Everything is still peachy if I want to run all of the tests with Build test
or prove
, but trying to run an individual test doesn't work:
drewfus:~/sandbox$ prove -lv SG::UtilsTest
Cannot determine source for SG::UtilsTest at /usr/share/perl/5.10/App/Prove.pm line 496