Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

mpeters (5802)

  (email not shown publicly)
AOL IM: michael00peters (Add Buddy, Send Message)

Technorati Profile []

Journal of mpeters (5802)

Saturday July 09, 2005
07:32 PM

Perty Testing Harness

[ #25612 ]
So I'm working on this web project that has a custom test harness and nightly automated tests. Right now it runs the tests using Test::Harness, captures the output and then emails it to everyone on the mailing list for the project. It's worked really well so far, but the output is kinda plain and because there are 96 test files, and 3000+ individual tests the test output is a little hard to skim quickly in the morning to make sure everything worked...

Enter Test::TAP::HTMLMatrix.

This module will run the desired tests, record the output from any TAP compatible tests (eg, anything using Test or Test::More, etc) and then format them into nice, pretty and colorful HTML results.

So I decided to try and capture this out and send out a multipart email using MIME::Lite. And the code looked something like this:

  # create the TAP model to run and capture the
  # TAP test output
  my $model = Test::TAP::Model::Visual->new();

  # now get the HTML output
  my $matrix = Test::TAP::HTMLMatrix->new($model);
  my $output = $matrix->html();

  # now send it in an email
  my $msg = MIME::Lite->new(
    From    => '',
    To      => ',
    Subject => 'Automated Test - ' . scalar(localtime),
    Type    => 'multipart/alternative',
    Type => 'text/html',
    Data => $email_output,

Pretty simple huh? But darn cool.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • That's neat. Would be great if there were a way that it could send only tests that failed so you can go straight to the any errors that occurred.
    • What's wrong with you, don't you like green :) I'm sure it can be done. It would just be a matter of messing with the Test::TAP::Model::Visual object. It contains all of the data resulting from the tests runs. Look at the docs for Test::TAP::Model, particularly at it's structure() method. I'm sure you could remove any passing tests from it's structure and then create an new Test::TAP::Model::Visual object from it. If you get something working, post it and then let us know.