On Aug 10, 2007, at 3:20 AM, Ovid wrote:
--- 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?
Right. I wasn't really advocating Test::Unit, I was just making the
point that there might be other class-based testing modules out there
besides Test::Class that could benefit from this.
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
That is a cool idea - I will have to create the emacs equivalent. :)
Still, it would be nice if there were a non-clunky (to use your
phrasing) way to specify the method that didn't require an editor macro.
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
Right. As I said in my email, this doesn't allow the convenience of
specifying a pattern, the way that TEST_METHOD does.
Jon
D