This is a real simple example of what you can do for sub classing. Object
oriented design is a wonderful thing :-D
################TEST HARNESS SUB CLASS (TestHarnessSubClass.pm)######
#!/usr/local/bin/perl
package TestHarnessSubClass;
use warnings;
use strict;
#This creates TestHarnessSubClass into a sub class of Test::Harness
use base "Test::Harness";
#####################################################################
####################################################################
# PROGRAM START ###################################################
####################################################################
#####################################################################
return 1;
#####################################################################
####################################################################
# PROGRAM ENDS ####################################################
####################################################################
#####################################################################
#####################################################################
####################################################################
# SUB ROUTINES ####################################################
####################################################################
#####################################################################
# over ridden method showing simple inheritance.
sub runtests{
my $self = shift;
print "LOOK I'M IN A SUB CLASS OF TEST HARNESS\n";
print "YOU CAN DO SOME STUFF HERE BEFORE CALLING TEST HARNESS' runtests
SUB ROUTINE!!!\n";
#you can do whatever you want to here and then pass along information to
#the super class if you want to. You don't have to call the super class
though.
#calls super classes runtests method.
$self->SUPER::runtests(@_);
}
####END OF TestHarnessSubClass.pm##################
###########################THE DRIVER PROGRAM (THDriver.pl)##########
#!/usr/local/bin/perl
use warnings;
use strict;
use TestHarnessSubClass;
#####################################################################
####################################################################
# PROGRAM START ###################################################
####################################################################
#####################################################################
TestHarnessSubClass::runtests('c:\perl\sample.t')
#####################################################################
####################################################################
# PROGRAM ENDS ####################################################
####################################################################
#####################################################################
##########################An extremely simple test class (sample.t)##
#!/usr/local/bin/perl
use warnings;
use strict;
use Test::More qw(no_plan);
#####################################################################
####################################################################
# PROGRAM START ###################################################
####################################################################
#####################################################################
&Test::More::is(1,1,"One equals One!!");
&Test::More::is(1,2,"Does one equal two??");
#####################################################################
####################################################################
# PROGRAM ENDS ####################################################
####################################################################
#####################################################################
---------------------------------------------------
Andrew Potozniak
Administrative Computing
Student Assistant
State University of New York at Buffalo
[EMAIL PROTECTED]
645-3587 x 7123
---------------------------------------------------
-----Original Message-----
From: Andrew Savige [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 23, 2003 8:56 PM
To: Potozniak, Andrew; [EMAIL PROTECTED]
Subject: Re: passing arguments to tests
"Potozniak, Andrew" wrote:
> Create a sub class of Test::Harness and or MakeMaker that will over-ride
> all of their methods/subroutines and then add what you want it to do,
> don't forget to call super classes' method/subroutine that you are
> over-riding. I can give an example of this if need be.
I'd be interested to see an example of sub-classing Test::Harness.
/-\
http://mobile.yahoo.com.au - Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.