Movatterモバイル変換


[0]ホーム

URL:


Test::Harness
(source,CPAN)
version 3.42
You are viewing the version of this documentation from Perl 5.30.2.View the latest version

CONTENTS

#NAME

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

#VERSION

Version 3.42

#SYNOPSIS

use Test::Harness;runtests(@test_files);

#DESCRIPTION

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

Emulation is provided forruntests andexecute_tests but the pluggable 'Straps' interface that previous versions ofTest::Harness supported is not reproduced here. Straps is now available as a stand alone module:Test::Harness::Straps.

SeeTAP::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 willdie() with one of the messages in the DIAGNOSTICS section.

#execute_tests( tests => \@test_files, out => \*FH )

Runs all the given@test_files (just likeruntests()) but doesn't generate the final report. During testing, progress information will be written to the currently selected output filehandle (usuallySTDOUT), or to the filehandle given by theout parameter. Theout 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:

bonus           Number of individual todo tests unexpectedly passedmax             Number of individual tests ranok              Number of individual tests passedsub_skipped     Number of individual tests skippedtodo            Number of individual todo testsfiles           Number of test files rangood            Number of test files passedbad             Number of test files failedtests           Number of test files originally givenskipped         Number of test files skipped

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:

name        Name of the test which failedestat       Script's exit valuewstat       Script's wait statusmax         Number of individual testsfailed      Number which failedcanon       List of tests which failed (as string).

$failed should be empty if everything passed.

#EXPORT

&runtests is exported byTest::Harness by default.

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

#ENVIRONMENT VARIABLES THAT TAP::HARNESS::COMPATIBLE SETS

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

#HARNESS_ACTIVE

This is set to a true value. It allows the tests to determine if they are being executed through the harness or by any other means.

#HARNESS_VERSION

This is the version ofTest::Harness.

#ENVIRONMENT VARIABLES THAT AFFECT TEST::HARNESS

#HARNESS_PERL_SWITCHES

Setting this adds perl command line switches to each test file run.

For example,HARNESS_PERL_SWITCHES=-T will turn on taint mode.HARNESS_PERL_SWITCHES=-MDevel::Cover will runDevel::Cover for each test.

-w is always set. You can turn this off in the test withBEGIN { $^W = 0 }.

#HARNESS_TIMER

Setting this to true will make the harness display the number of milliseconds each test took. You can also useprove's--timer switch.

#HARNESS_VERBOSE

If true,Test::Harness will output the verbose results of running its tests. Setting$Test::Harness::verbose will override this, or you can use the-v switch in theprove utility.

#HARNESS_OPTIONS

Provide additional options to the harness. Currently supported options are:

#j<n>

Run <n> (default 9) parallel jobs.

#c

Try to color output. See"new" in TAP::Formatter::Base.

#a<file.tgz>

Will useTAP::Harness::Archive as the harness class, and save the TAP tofile.tgz

#fPackage-With-Dashes

Set the formatter_class of the harness being run. Since theHARNESS_OPTIONS is seperated by:, we use- instead.

Multiple options may be separated by colons:

HARNESS_OPTIONS=j9:c make test
#HARNESS_SUBCLASS

Specifies a TAP::Harness subclass to be used in place of TAP::Harness.

#HARNESS_SUMMARY_COLOR_SUCCESS

Determines theTerm::ANSIColor for the summary in case it is successful. This color defaults to'green'.

#HARNESS_SUMMARY_COLOR_FAIL

Determines theTerm::ANSIColor for the failure in case it is successful. This color defaults to'red'.

#Taint Mode

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

BecausePERL5LIB is often used during testing to add build directories to@INCTest::Harness passes the names of any directories found inPERL5LIB as -I switches. The net effect of this is thatPERL5LIB is honoured even in taint mode.

#SEE ALSO

TAP::Harness

#BUGS

Please report any bugs or feature requests tobug-test-harness at rt.cpan.org, or through the web interface athttp://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@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 forsure is, that it was inspired by Larry Wall's F<TEST> script that camewith perl distributions for ages. Numerous anonymous contributorsexist.  Andreas Koenig held the torch for many years, and thenMichael G Schwern.

#LICENCE AND COPYRIGHT

Copyright (c) 2007-2011, Andy Armstrong<andy@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. Seeperlartistic.

Perldoc Browser is maintained by Dan Book (DBOOK). Please contact him via theGitHub issue tracker oremail regarding any issues with the site itself, search, or rendering of documentation.

The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via thePerl issue tracker, themailing list, orIRC to report any issues with the contents or format of the documentation.


[8]ページ先頭

©2009-2025 Movatter.jp