Cari di Perl 
    Perl User Manual
Daftar Isi
(Sebelumnya) Iconv(1), reinvented in perlA stream editor (Berikutnya)
Utilities

Run tests through a TAP harness.

Daftar Isi

NAME

prove - Run tests through a TAP harness.

USAGE

  1. prove [options] [files or directories]

OPTIONS

Boolean options:

  1. -v, --verbose Print all test lines.
  2. -l, --lib Add 'lib' to the path for your tests (-Ilib).
  3. -b, --blib Add 'blib/lib' and 'blib/arch' to the path for
  4. your tests
  5. -s, --shuffle Run the tests in random order.
  6. -c, --color Colored test output (default).
  7. --nocolor Do not color test output.
  8. --count Show the X/Y test count when not verbose
  9. (default)
  10. --nocount Disable the X/Y test count.
  11. -D --dry Dry run. Show test that would have run.
  12. --ext Set the extension for tests (default '.t')
  13. -f, --failures Show failed tests.
  14. -o, --comments Show comments.
  15. --ignore-exit Ignore exit status from test scripts.
  16. -m, --merge Merge test scripts' STDERR with their STDOUT.
  17. -r, --recurse Recursively descend into directories.
  18. --reverse Run the tests in reverse order.
  19. -q, --quiet Suppress some test output while running tests.
  20. -Q, --QUIET Only print summary results.
  21. -p, --parse Show full list of TAP parse errors, if any.
  22. --directives Only show results with TODO or SKIP directives.
  23. --timer Print elapsed time after each test.
  24. --trap Trap Ctrl-C and print summary on interrupt.
  25. --normalize Normalize TAP output in verbose output
  26. -T Enable tainting checks.
  27. -t Enable tainting warnings.
  28. -W Enable fatal warnings.
  29. -w Enable warnings.
  30. -h, --help Display this help
  31. -?, Display this help
  32. -H, --man Longer manpage for prove
  33. --norc Don't process default .proverc

Options that take arguments:

  1. -I Library paths to include.
  2. -P Load plugin (searches App::Prove::Plugin::*.)
  3. -M Load a module.
  4. -e, --exec Interpreter to run the tests ('' for compiled
  5. tests.)
  6. --harness Define test harness to use. See TAP::Harness.
  7. --formatter Result formatter to use. See FORMATTERS.
  8. --source Load and/or configure a SourceHandler. See
  9. SOURCE HANDLERS.
  10. -a, --archive out.tgz Store the resulting TAP in an archive file.
  11. -j, --jobs N Run N test jobs in parallel (try 9.)
  12. --state=opts Control prove's persistent state.
  13. --rc=rcfile Process options from rcfile

NOTES

.proverc

If ~/.proverc or ./.proverc exist they will be read and anyoptions they contain processed before the command line options. Optionsin .proverc are specified in the same way as command line options:

  1. # .proverc
  2. --state=hot,fast,save
  3. -j9

Additional option files may be specified with the --rc option.Default option file processing is disabled by the --norc option.

Under Windows and VMS the option file is named _proverc rather than.proverc and is sought only in the current directory.

Reading from STDIN

If you have a list of tests (or URLs, or anything else you want to test) in afile, you can add them to your tests by using a '-':

  1. prove - < my_list_of_things_to_test.txt

See the README in the examples directory of this distribution.

Default Test Directory

If no files or directories are supplied, prove looks for all filesmatching the pattern t/*.t.

Colored Test Output

Colored test output is the default, but if output is not to aterminal, color is disabled. You can override this by adding the--color switch.

Color support requires Term::ANSIColor on Unix-like platforms andWin32::Console windows. If the necessary module is not installedcolored output will not be available.

Exit Code

If the tests fail prove will exit with non-zero status.

Arguments to Tests

It is possible to supply arguments to tests. To do so separate them fromprove's own arguments with the arisdottle, '::'. For example

  1. 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.

--exec

Normally you can just pass a list of Perl tests and the harness will know howto execute them. However, if your tests are not written in Perl or if youwant all tests invoked exactly the same way, use the -e, or --execswitch:

  1. prove --exec '/usr/bin/ruby -w' t/
  2. prove --exec '/usr/bin/perl -Tw -mstrict -Ilib' t/
  3. prove --exec '/path/to/my/customer/exec'

--merge

If you need to make sure your diagnostics are displayed in the correctorder relative to test results you can use the --merge option tomerge the test scripts' STDERR into their STDOUT.

This guarantees that STDOUT (where the test results appear) and STDOUT(where the diagnostics appear) will stay in sync. The harness willdisplay any diagnostics your tests emit on STDERR.

Caveat: this is a bit of a kludge. In particular note that if anythingthat appears on STDERR looks like a test result the test harness willget confused. Use this option only if you understand the consequencesand can live with the risk.

--trap

The --trap option will attempt to trap SIGINT (Ctrl-C) during a testrun and display the test summary even if the run is interrupted

--state

You can ask prove to remember the state of previous test runs andselect and/or order the tests to be run based on that saved state.

The --state switch requires an argument which must be a commaseparated list of one or more of the following options.

  • last

    Run the same tests as the last time the state was saved. This makes itpossible, for example, to recreate the ordering of a shuffled test.

    1. # Run all tests in random order
    2. $ prove -b --state=save --shuffle
    3. # Run them again in the same order
    4. $ prove -b --state=last
  • failed

    Run only the tests that failed on the last run.

    1. # Run all tests
    2. $ prove -b --state=save
    3. # Run failures
    4. $ prove -b --state=failed

    If you also specify the save option newly passing tests will beexcluded from subsequent runs.

    1. # Repeat until no more failures
    2. $ prove -b --state=failed,save
  • passed

    Run only the passed tests from last time. Useful to make sure that nonew problems have been introduced.

  • all

    Run all tests in normal order. Multple options may be specified, so torun all tests with the failures from last time first:

    1. $ prove -b --state=failed,all,save
  • hot

    Run the tests that most recently failed first. The last failure time ofeach test is stored. The hot option causes tests to be run in most-recent-failure order.

    1. $ prove -b --state=hot,save

    Tests that have never failed will not be selected. To run all tests withthe most recently failed first use

    1. $ prove -b --state=hot,all,save

    This combination of options may also be specified thus

    1. $ prove -b --state=adrian
  • todo

    Run any tests with todos.

  • slow

    Run the tests in slowest to fastest order. This is useful in conjunctionwith the -j parallel testing switch to ensure that your slowest testsstart running first.

    1. $ prove -b --state=slow -j9
  • fast

    Run test tests in fastest to slowest order.

  • new

    Run the tests in newest to oldest order based on the modification timesof the test scripts.

  • old

    Run the tests in oldest to newest order.

  • fresh

    Run those test scripts that have been modified since the last test run.

  • save

    Save the state on exit. The state is stored in a file called .prove(_prove on Windows and VMS) in the current directory.

The --state switch may be used more than once.

  1. $ prove -b --state=hot --state=all,save

@INC

prove introduces a separation between "options passed to the perl whichruns prove" and "options passed to the perl which runs tests"; thisdistinction is by design. Thus the perl which is running a test startswith the default @INC. Additional library directories can be addedvia the PERL5LIB environment variable, via -Ifoo in PERL5OPT orvia the -Ilib option to prove.

Taint Mode

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

Because PERL5LIB is often used during testing to add builddirectories to @INC prove passes the names of any directories foundin PERL5LIB as -I switches. The net effect of this is thatPERL5LIB is honoured even when prove is run in taint mode.

FORMATTERS

You can load a custom TAP::Parser::Formatter:

  1. prove --formatter MyFormatter

SOURCE HANDLERS

You can load custom TAP::Parser::SourceHandlers, to change the way theparser interprets particular sources of TAP.

  1. prove --source MyHandler --source YetAnother t

If you want to provide config to the source you can use:

  1. prove --source MyCustom \
  2. --source Perl --perl-option 'foo=bar baz' --perl-option avg=0.278 \
  3. --source File --file-option extensions=.txt --file-option extensions=.tmp t
  4. --source pgTAP --pgtap-option pset=format=html --pgtap-option pset=border=2

Each --$source-option option 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 hashreference, specify the value as a second pair separated by a =, as in thepset= examples above (escape = with a backslash).

All --sources are combined into a hash, and passed to new in TAP::Harness'ssources parameter.

See TAP::Parser::IteratorFactory for more details on how configuration ispassed to SourceHandlers.

PLUGINS

Plugins can be loaded using the -Pplugin syntax, eg:

  1. prove -PMyPlugin

This will search for a module named App::Prove::Plugin::MyPlugin, or failingthat, MyPlugin. If the plugin can't be found, prove will complain & exit.

You can pass arguments to your plugin by appending =arg1,arg2,etc to theplugin name:

  1. prove -PMyPlugin=fou,du,fafa

Please check individual plugin documentation for more details.

Available Plugins

For an up-to-date list of plugins available, please check CPAN:

http://search.cpan.org/search?query=App%3A%3AProve+Plugin

Writing Plugins

Please see PLUGINS in App::Prove.

 
Source : perldoc.perl.org - Official documentation for the Perl programming language
Site maintained by Jon Allen (JJ)     See the project page for more details
Documentation maintained by the Perl 5 Porters
(Sebelumnya) Iconv(1), reinvented in perlA stream editor (Berikutnya)