badaiaqrandista has asked for the wisdom of the Perl Monks concerning the following question:
Hi All,
I am starting to build unit test for an existing software with Test::Class. How do you suggest organizing these test classes so they are easily run by Test::Harness? Unfortunately the code is not created using ExtUtils::MakeMaker and h2xs so I need to write my own script to run the test classes.
This is my runtest.pl script:
#!/usr/bin/perl use strict; use warnings; use Test::Class; my @test_classes; BEGIN { my @test_class_files; if (@ARGV) { push @test_class_files, @ARGV; } else { my @test_class_files = glob "UnitTest/*.pm"; } foreach my $i (@test_class_files) { if ($i =~ /\//) { $i =~ s/\//::/g; $i =~ s/\.pm$//; } push @test_classes, $i; } foreach my $i (@test_classes) { eval "require $i"; die $@ if $@; } } Test::Class->runtests;
The code is structured this way: Each application module has its counterpart under UnitTest namespace. For example: ELRes::Room tests are written in UnitTest::ELRes::Room class.
And this is how I run that script:
$ ./runtest.pl UnitTest/ELRes/Room.pm OR $ ./runtest.pl UnitTest::ELRes::Room
Or to run all test classes, I only need to call 'runtest.pl' without parameters.
I have no idea of how to convert this script into using Test::Harness as if each test class is a .t script. Can anyone help me with this?
Thanks for your help...
UPDATE: Explained how I expect the code to work and the directory structure it expects to have
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Organizing Test::Class tests with Test::Harness
by chromatic (Archbishop) on Sep 07, 2007 at 06:33 UTC | |
by badaiaqrandista (Pilgrim) on Sep 09, 2007 at 22:52 UTC | |
|
Re: Organizing Test::Class tests with Test::Harness
by moritz (Cardinal) on Sep 07, 2007 at 06:22 UTC |