--- Jonathan Swartz <[EMAIL PROTECTED]> wrote:
> I'm wondering if any Test::Class (or Test::Unit, etc.) users out
> there have yearned for a more convenient way to specify which classes
> and methods to run, and if there's any reasonable way to add this
> capability to prove, given that the options would make no sense for
> traditional non-class tests.
Unless Test::Unit has changed recently, I wouldn't use it. As I
recall, it was an interesting attempt to port xUnit style tests to
Perl. As a result, it cannot take advantage of the large set of
testing module we have on the CPAN. Has this changed?
As for running an individual test method, I use the following mapping
in vim:
noremap ,tm ?^sub.*:.*Test<cr>w"zyeOBEGIN { $ENV{TEST_METHOD} =
'<c-r>z' }<esc>
I explain how it works at:
http://use.perl.org/~Ovid/journal/33567
As for running an individual test class, many people make their driver
script the following:
#!/usr/bin/perl
use strict;
use warnings;
use Test::Class::Load 't/tests';
Test::Class->runtests;
However, a better strategy is to *remove* that runtests() method call
and put it in the INIT block of your base class for your tests. A
simple one would look like this:
package My::Test::Class;
use strict;
use warnings;
use base 'Test::Class';
INIT { Test::Class->runtests }
# season to taste
1;
Then you can run an individual test class (named, for example,
Tests::My::Customer) with something like this:
prove -l -It/lib -It/tests/ t/tests/Tests/My/Customer.pm
If the runtests call is in the driver script, then only that script can
run your tests. Pull it out and put it in your base class and life is
good :)
You can read more about this with 'perldoc Test::Class::Load'.
Cheers,
Ovid
--
Buy the book - http://www.oreilly.com/catalog/perlhks/
Perl and CGI - http://users.easystreet.com/ovid/cgi_course/
Personal blog - http://publius-ovidius.livejournal.com/
Tech blog - http://use.perl.org/~Ovid/journal/