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

-cheepy-

In reply to Organizing Test::Class tests with Test::Harness by badaiaqrandista

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.