Perty Testing Harness

mpeters on 2005-07-10T00:32:56

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();
  $model->run_tests(@testfiles);

# 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 => 'testing@plusthree.com', To => 'project_list@plusthree.com, Subject => 'Automated Test - ' . scalar(localtime), Type => 'multipart/alternative', ); $msg->attach( Type => 'text/html', Data => $email_output, ); $msg->send()


Pretty simple huh? But darn cool.


Cool

Phred on 2005-07-20T17:31:37

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.

Re:Cool

mpeters on 2005-07-20T19:30:12

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.