perldoc > Test::Harness

๐Ÿ“› NAME

Test::Harness - Run Perl standard test scripts with statistics

๐Ÿ”– VERSION

Version 3.43

๐Ÿ“‹ SYNOPSIS

  use Test::Harness;

  runtests(@test_files);

๐Ÿš€ Quick Reference

Use CaseCommandDescription
Run test filesruntests(@test_files)๐Ÿงช Execute tests and print summary report
Programmatic test executionexecute_tests(tests => \@test_files)๐Ÿ“Š Run tests without report, returns results hash
Verbose outputHARNESS_VERBOSE=1 or prove -v๐Ÿ”Š Show detailed test output
Parallel testingHARNESS_OPTIONS=j9โšก Run up to 9 tests in parallel
Color outputHARNESS_OPTIONS=c๐ŸŽจ Colorize test results

๐Ÿ“ DESCRIPTION

Although, for historical reasons, the Test::Harness distribution takes its name from this module it now exists only to provide TAP::Harness with an interface that is somewhat backwards compatible with Test::Harness 2.xx. If you're writing new code consider using TAP::Harness directly instead.

Emulation is provided for "runtests" and "execute_tests" but the pluggable 'Straps' interface that previous versions of Test::Harness supported is not reproduced here. Straps is now available as a stand alone module: Test::Harness::Straps.

See TAP::Parser, TAP::Harness for the main documentation for this distribution.

โš™๏ธ FUNCTIONS

The following functions are available.

๐Ÿ”ฌ runtests( @test_files )

This runs all the given @test_files and divines whether they passed or failed based on their output to STDOUT (details above). It prints out each individual test which failed along with a summary report and a how long it all took.

It returns true if everything was ok. Otherwise it will "die()" with one of the messages in the DIAGNOSTICS section.

๐Ÿ”ฌ execute_tests( tests => \@test_files, out => \*FH )

Runs all the given @test_files (just like "runtests()") but doesn't generate the final report. During testing, progress information will be written to the currently selected output filehandle (usually "STDOUT"), or to the filehandle given by the "out" parameter. The out is optional.

Returns a list of two values, $total and $failed, describing the results. $total is a hash ref summary of all the tests run. Its keys and values are this:

If "$total->{bad} == 0" and "$total->{max} > 0", you've got a successful test.

$failed is a hash ref of all the test scripts that failed. Each key is the name of a test script, each value is another hash representing how that script failed. Its keys are these:

$failed should be empty if everything passed.

๐Ÿ“ฆ EXPORT

&runtests is exported by "Test::Harness" by default.

&execute_tests, $verbose, $switches and $debug are exported upon request.

๐ŸŒ ENVIRONMENT VARIABLES

๐Ÿ”ง Set by Test::Harness

"Test::Harness" sets these before executing the individual tests.

โš™๏ธ Affecting Test::Harness

๐Ÿ”’ Taint Mode

Normally when a Perl program is run in taint mode the contents of the "PERL5LIB" environment variable do not appear in @INC.

Because "PERL5LIB" is often used during testing to add build directories to @INC "Test::Harness" passes the names of any directories found in "PERL5LIB" as -I switches. The net effect of this is that "PERL5LIB" is honoured even in taint mode.

๐Ÿ‘๏ธ SEE ALSO

TAP::Harness

๐Ÿ› BUGS

Please report any bugs or feature requests to "bug-test-harness at rt.cpan.org", or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Harness. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

๐Ÿ‘ค AUTHORS

Andy Armstrong "<andy AT hexten.net>"

Test::Harness 2.64 (maintained by Andy Lester and on which this module is based) has this attribution:

Either Tim Bunce or Andreas Koenig, we don't know. What we know for sure is, that it was inspired by Larry Wall's F<TEST> script that came with perl distributions for ages. Numerous anonymous contributors exist. Andreas Koenig held the torch for many years, and then Michael G Schwern.

๐Ÿ“„ LICENCE AND COPYRIGHT

Copyright (c) 2007-2011, Andy Armstrong "<andy AT hexten.net>". All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

Test::Harness
๐Ÿ“› NAME ๐Ÿ”– VERSION ๐Ÿ“‹ SYNOPSIS ๐Ÿš€ Quick Reference ๐Ÿ“ DESCRIPTION โš™๏ธ FUNCTIONS
๐Ÿ”ฌ runtests( @test_files ) ๐Ÿ”ฌ execute_tests( tests => \@test_files, out => \*FH )
๐Ÿ“ฆ EXPORT ๐ŸŒ ENVIRONMENT VARIABLES
๐Ÿ”ง Set by Test::Harness โš™๏ธ Affecting Test::Harness ๐Ÿ”’ Taint Mode
๐Ÿ‘๏ธ SEE ALSO ๐Ÿ› BUGS ๐Ÿ‘ค AUTHORS ๐Ÿ“„ LICENCE AND COPYRIGHT

Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-31 00:06 @216.73.217.152
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^