Test.Harness - Run TAP standard JavaScript test scripts with statistics
Test.Harness.runTests('foo.js', bar.js');
STOP! If all you want to do is write a test script, consider using Test.Simple. Test.Harness is the module that reads the output from Test.Simple, Test.More and other modules based on Test.Builder. You don't need to know about Test.Harness to use those modules.
STOP AGAIN! Test.Harness is an abstract base class. See Test.Harness.Browser for a concrete subclass offering a browser-based harness.
Test.Harness runs tests and expects to get the results from the TestResults
attribute of the Test.Builder object. These results conform to a format called TAP, the Test Anything Protocol. It is defined in http://search.cpan.org/dist/Test-Harness/lib/Test/Harness/TAP.pod.
When tests fail, analyze the summary report:
base.html..............ok
nonumbers.js...........ok
ok.js..................ok
test-harness.js........ok
waterloo.html..........dubious
DIED. FAILED tests 1, 3, 5, 7, 9, 11, 13, 15, 17, 19
Failed 10/20 tests, 50.00% okay
Failed Test Total Fail Failed List of Failed
-------------------------------------------------------------
waterloo.html 20 10 50.00% 1 3 5 7 9 11 13 15 17 19
Failed 1/5 test scripts, 80.00% okay. 10/44 subtests failed, 77.27% okay.
Everything passed but waterloo.html. It failed 10 of 20 tests.
The columns in the summary report mean:
Test.Harness.runTests('testone.js', 'testtwo.js');
Constructs a new Test.Harness object and calls its runTests()
instance method, passing all arguments along.
var harness = new Test.Harness();
Constructs a new Test.Harness object.
harness.runTests('testone.js', 'testtwo.js');
TestRusults
attribute of their global Test.Builder.Test
object. It prints out each individual test that failed along with a summary report and a how long it all took. When all tests have been run, a diagnostic message will be output. var encoding = harness.encoding();
harness = harness.encoding(encoding);
null
by default, and therefore unset.All tests successful.\nFiles=%d, Tests=%d, %s
FAILED tests %s\n\tFailed %d/%d tests, %.2f%% okay.
Failed 1 test, %.2f%% okay. %s
Failed %d/%d tests, %.2f%% okay. %s
Test.Simple and Test.More, modules with which to write tests.
David Wheeler <david@kineticode.com>, based on the original Test::Harness included with Perl.
Copyright 2005 by David Wheeler <david@kineticode.com>
This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License or the GNU GPL.
See http://www.perl.com/perl/misc/Artistic.html and http://www.gnu.org/copyleft/gpl.html.