Harness


This is a module that can analyze the ok / not ok printouts with the numbers. In particular, it can analyze the output of Test::Simple and a whole class of other modules in the Test::* namespace on CPAN we are going to see later.

The harness.pl script is just a sample usage of the Test::Harness module. It accepts one or more test files, runs them and analyzes the output they generated.


examples/root/harness.pl
#!/usr/bin/perl
use strict;
use warnings;

use Test::Harness qw(runtests);

runtests @ARGV;

Run the previous test file using Test::Harness


$ perl ../root/harness.pl tests/t24.pl

If the original test script had very few test units then this output won't make much sense, but if the original test script had hundreds of OKs, we would not be really interested on all those OKs. We would be mainly interested in a summary, and in the (hopefully) little number of "NOT OK" printouts. This is how the output of Test::Harness looks like:

tests/t24.......
#   Failed test '2 + 2 + 2'
#   at tests/t24.pl line 28.
# Looks like you failed 1 test of 45.
 Dubious, test returned 1 (wstat 256, 0x100)
 Failed 1/45 subtests

Test Summary Report
-------------------
tests/t24.pl (Wstat: 256 Tests: 45 Failed: 1)
  Failed test:  3
  Non-zero exit status: 1
Files=1, Tests=45,  0 wallclock secs
   ( 0.01 usr  0.00 sys +  0.02 cusr  0.00 csys =  0.03 CPU)
Result: FAIL
Failed 1/1 test programs. 1/45 subtests failed.