I'm afraid your code won't work.

> package TestHarnessSubClass;
[snip]
> #This creates TestHarnessSubClass into a sub class of Test::Harness
> use base "Test::Harness";
[snip]
> sub runtests{
>   my $self = shift;
[snip]
>   $self->SUPER::runtests(@_);
> } 

Okay, you've subclassed a functional module.  But this means that you'll be passing 
the package
name as the first argument, not a test name.  This will generate a "this test does not 
exist"
warning with the package name as the name of the first test that it's trying to run.

On a minor side note, $self in Perl typically refers to an instance.  If this were a 
proper class
method, $class would be a better name for that argument.

> use TestHarnessSubClass;
> TestHarnessSubClass::runtests('c:\perl\sample.t')

You subclassed Test::Harness, but here you are still calling this in a functional 
manner (instead
of TestHarnessSubClass->runtests), which means that C:\perl\sample.t will be passed as 
the first
argument.  The "subclassed" runtests() method will assign that value to $self and you 
will have
very disappointing results.

In short, don't try to subclass modules unless they're OO.

Cheers,
Ovid


=====
Hire me!                   http://users.easystreet.com/ovid/personal/resume.html
Silence is Evil            http://users.easystreet.com/ovid/philosophy/indexdecency.htm
Ovid                       http://www.perlmonks.org/index.pl?node_id=17000
Web Programming with Perl  http://users.easystreet.com/ovid/cgi_course/

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Reply via email to