05 Jun 2012 16:18:36 UTC
- Distribution: Test-Harness
- Source (raw)
- Browse (raw)
- How to Contribute
- Clone repository
- Issues (61)
- Testers (652 / 25 / 0)
- KwaliteeBus factor: 5
- License: perl_5
- Activity24 month
- Download (290.69KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:26 non-PAUSE usersOVID Curtis "Ovid" Poeand 1 contributors
- SOURCE HANDLERS
prove - Run tests through a TAP harness.
prove [options] [files or directories]
-v, --verbose Print all test lines. -l, --lib Add 'lib' to the path for your tests (-Ilib). -b, --blib Add 'blib/lib' and 'blib/arch' to the path for your tests -s, --shuffle Run the tests in random order. -c, --color Colored test output (default). --nocolor Do not color test output. --count Show the X/Y test count when not verbose (default) --nocount Disable the X/Y test count. -D --dry Dry run. Show test that would have run. --ext Set the extension for tests (default '.t') -f, --failures Show failed tests. -o, --comments Show comments. --ignore-exit Ignore exit status from test scripts. -m, --merge Merge test scripts' STDERR with their STDOUT. -r, --recurse Recursively descend into directories. --reverse Run the tests in reverse order. -q, --quiet Suppress some test output while running tests. -Q, --QUIET Only print summary results. -p, --parse Show full list of TAP parse errors, if any. --directives Only show results with TODO or SKIP directives. --timer Print elapsed time after each test. --trap Trap Ctrl-C and print summary on interrupt. --normalize Normalize TAP output in verbose output -T Enable tainting checks. -t Enable tainting warnings. -W Enable fatal warnings. -w Enable warnings. -h, --help Display this help -?, Display this help -H, --man Longer manpage for prove --norc Don't process default .proverc
Options that take arguments:
-I Library paths to include. -P Load plugin (searches App::Prove::Plugin::*.) -M Load a module. -e, --exec Interpreter to run the tests ('' for compiled tests.) --harness Define test harness to use. See TAP::Harness. --formatter Result formatter to use. See FORMATTERS. --source Load and/or configure a SourceHandler. See SOURCE HANDLERS. -a, --archive out.tgz Store the resulting TAP in an archive file. -j, --jobs N Run N test jobs in parallel (try 9.) --state=opts Control prove's persistent state. --rc=rcfile Process options from rcfile
If ~/.proverc or ./.proverc exist they will be read and any options they contain processed before the command line options. Options in .proverc are specified in the same way as command line options:
# .proverc --state=hot,fast,save -j9
Additional option files may be specified with the
--rcoption. Default option file processing is disabled by the
Under Windows and VMS the option file is named _proverc rather than .proverc and is sought only in the current directory.
If you have a list of tests (or URLs, or anything else you want to test) in a file, you can add them to your tests by using a '-':
prove - < my_list_of_things_to_test.txt
examplesdirectory of this distribution.
If no files or directories are supplied,
provelooks for all files matching the pattern
Colored test output is the default, but if output is not to a terminal, color is disabled. You can override this by adding the
If the tests fail
provewill exit with non-zero status.
It is possible to supply arguments to tests. To do so separate them from prove's own arguments with the arisdottle, '::'. For example
prove -v t/mytest.t :: --url http://example.com
would run t/mytest.t with the options '--url http://example.com'. When running multiple tests they will each receive the same arguments.
Normally you can just pass a list of Perl tests and the harness will know how to execute them. However, if your tests are not written in Perl or if you want all tests invoked exactly the same way, use the
prove --exec '/usr/bin/ruby -w' t/ prove --exec '/usr/bin/perl -Tw -mstrict -Ilib' t/ prove --exec '/path/to/my/customer/exec'
If you need to make sure your diagnostics are displayed in the correct order relative to test results you can use the
--mergeoption to merge the test scripts' STDERR into their STDOUT.
This guarantees that STDOUT (where the test results appear) and STDERR (where the diagnostics appear) will stay in sync. The harness will display any diagnostics your tests emit on STDERR.
Caveat: this is a bit of a kludge. In particular note that if anything that appears on STDERR looks like a test result the test harness will get confused. Use this option only if you understand the consequences and can live with the risk.
--trapoption will attempt to trap SIGINT (Ctrl-C) during a test run and display the test summary even if the run is interrupted
You can ask
proveto remember the state of previous test runs and select and/or order the tests to be run based on that saved state.
--stateswitch requires an argument which must be a comma separated list of one or more of the following options.
Run the same tests as the last time the state was saved. This makes it possible, for example, to recreate the ordering of a shuffled test.
# Run all tests in random order $ prove -b --state=save --shuffle # Run them again in the same order $ prove -b --state=last
Run only the tests that failed on the last run.
# Run all tests $ prove -b --state=save # Run failures $ prove -b --state=failed
If you also specify the
saveoption newly passing tests will be excluded from subsequent runs.
# Repeat until no more failures $ prove -b --state=failed,save
Run only the passed tests from last time. Useful to make sure that no new problems have been introduced.
Run all tests in normal order. Multple options may be specified, so to run all tests with the failures from last time first:
$ prove -b --state=failed,all,save
Run the tests that most recently failed first. The last failure time of each test is stored. The
hotoption causes tests to be run in most-recent- failure order.
$ prove -b --state=hot,save
Tests that have never failed will not be selected. To run all tests with the most recently failed first use
$ prove -b --state=hot,all,save
This combination of options may also be specified thus
$ prove -b --state=adrian
Run any tests with todos.
Run the tests in slowest to fastest order. This is useful in conjunction with the
-jparallel testing switch to ensure that your slowest tests start running first.
$ prove -b --state=slow -j9
Run test tests in fastest to slowest order.
Run the tests in newest to oldest order based on the modification times of the test scripts.
Run the tests in oldest to newest order.
Run those test scripts that have been modified since the last test run.
Save the state on exit. The state is stored in a file called .prove (_prove on Windows and VMS) in the current directory.
--stateswitch may be used more than once.
$ prove -b --state=hot --state=all,save
prove introduces a separation between "options passed to the perl which runs prove" and "options passed to the perl which runs tests"; this distinction is by design. Thus the perl which is running a test starts with the default
@INC. Additional library directories can be added via the
PERL5LIBenvironment variable, via -Ifoo in
PERL5OPTor via the
-Iliboption to prove.
Normally when a Perl program is run in taint mode the contents of the
PERL5LIBenvironment variable do not appear in
PERL5LIBis often used during testing to add build directories to
@INCprove passes the names of any directories found in
PERL5LIBas -I switches. The net effect of this is that
PERL5LIBis honoured even when prove is run in taint mode.
You can load a custom TAP::Parser::Formatter:
prove --formatter MyFormatter
You can load custom TAP::Parser::SourceHandlers, to change the way the parser interprets particular sources of TAP.
prove --source MyHandler --source YetAnother t
If you want to provide config to the source you can use:
prove --source MyCustom \ --source Perl --perl-option 'foo=bar baz' --perl-option avg=0.278 \ --source File --file-option extensions=.txt --file-option extensions=.tmp t --source pgTAP --pgtap-option pset=format=html --pgtap-option pset=border=2
--$source-optionoption must specify a key/value pair separated by an
=. If an option can take multiple values, just specify it multiple times, as with the
extensions=examples above. If the option should be a hash reference, specify the value as a second pair separated by a
=, as in the
pset=examples above (escape
=with a backslash).
--sourcesare combined into a hash, and passed to "new" in TAP::Harness's
See TAP::Parser::IteratorFactory for more details on how configuration is passed to SourceHandlers.
Plugins can be loaded using the
This will search for a module named
App::Prove::Plugin::MyPlugin, or failing that,
MyPlugin. If the plugin can't be found,
provewill complain & exit.
You can pass arguments to your plugin by appending
=arg1,arg2,etcto the plugin name:
Please check individual plugin documentation for more details.
For an up-to-date list of plugins available, please check CPAN:
Please see "PLUGINS" in App::Prove.
Module Install Instructions
To install Test::Harness, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Test::Harness
For more information on module installation, please visit the detailed CPAN module installation guide.