for this type of testing. Here's a bit of code I use to run a bunch of tests and get a nice report (it's inspired by chromatic's
#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
use Cwd;
use Text::Reform qw( form );
use Data::Dumper;
use Getopt::Long;
use Pod::Usage;
use Test::Harness::Straps;
my $strap = Test::Harness::Straps->new();
our( @status, @filename, @expected, @run, @passed, @skipped, @todo, @t
+odo_skipped );
our( $opt_help, $opt_path, $opt_email, $opt_noprint );
GetOptions( "help|h" => \$opt_help,
"path|p=s" => \$opt_path,
"email|e=s" => \$opt_email,
"noprint|n" => \$opt_noprint,
);
pod2usage( -verbose => 2 ) if $opt_help;
my $path = getcwd unless $opt_path;
find( { wanted => \&test_found, no_chdir => 1 }, $path );
my $report_date = localtime( time );
my $alert = form
'',
"Test suite at $path",
"Report Date: $report_date",
'',
' ===========================
+=========================',
' Te
+sts ',
' ===========================
+=========================',
'Status Filename Expected Run Passed Sk
+ipped TODO TODO Skipped',
'---------------------------------------------------------------------
+-------------------------',
'|||| [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ ||| ||| |||
+||| ||| |||',
\@status, \@filename, \@expected, \@run, \@passed, \@skipped, \@todo,
+\@todo_skipped;
print $alert unless $opt_noprint;
send_mail( $alert, "Test Suite: $path", $opt_email ) if $opt_email;
sub send_mail{
my ( $alert, $subject, $to_email ) = @_;
# Send email here
}
sub test_found{
return unless m/\.t$/;
return if $File::Find::name =~ m/exclude_tests/i;
my %results = $strap->analyze_file( $File::Find::name );
my $status = 'FAIL';
$status = ' OK ' if $results{'max'} == $results{'seen'} && $result
+s{'seen'} == $results{'ok'};
my ( $file ) = $File::Find::name;
$file =~ s/$path//;;
push @status, $status;
push @filename, $file;
push @expected, $results{'max'};
push @run, $results{'seen'};
push @passed, $results{'ok'};
push @skipped, $results{'skip'};
push @todo, $results{'todo'};
push @todo_skipped, $results{'bonus'};
}
1;
__END__
=head1 NAME
test_harness.pl - Main test harness script.
=head1 SYNOPSIS
test_harness.pl --path <path to tests> --help
--path, -p: Path to look for tests - will run all tests found. Defau
+lts to ./t.
--email, -e: Email address to send report to. If ommitted, no report
+ is sent.
--noprint, n: Suppress printing report to STDOUT.
--help, -h: This message.
=head1 AUTHOR
Troy Denkinger (tdenkinger at gmail.com)
=head1 VERSION
Version 1.0
=head1 COPYRIGHT
Copyright (c) 2005 by Troy Denkinger. This program is free software;
+you can redistribute it and/or modify it under the same terms as Perl
+ itself.
=cut
I'm not sure how I'd handle the long running tests. Maybe output the results to a file you can come back and pick up later. The key is getting the browser to disconnect and keep the test running.