On Apr 13, 2011, at 10:16 AM, Jozef Kutej wrote:
> On 2011-04-13 06:40, Ovid wrote:
>> If you're talking about rerunning the package tests on a module after it's
>> been
>> installed, I had been working on the idea of installing tests along with the
>> code. This would require a few things:
>>
>> 1. A place to install the tests.
I put Test::Class-based tests in the lib/ that's installed, under MyApp::Test,
for example. These test classes inherit from a common base test class which has
INIT { Test::Class->runtests }
like Ovid describes in
http://www.modernperlbooks.com/mt/2009/03/making-your-testing-life-easier.html
To load them, I have a test runner class:
package MyApp::TestX::Runner;
use warnings;
use strict;
sub import {
my ($class, @search_path) = @_;
require Module::Pluggable;
Module::Pluggable->import(
search_path => \@search_path,
require => 1
);
__PACKAGE__->plugins;
}
Loading the "pluggable" test classes is done in import(), which runs during
BEGIN,
so the classes loaded there during INIT.
Now you can run tests with
perl -MMyApp::TestX::Runner=MyApp::Test -e1
You can also run an individual test class with
perl -MMyApp::Test::Foo::Bar -e1
Marcel