Test Anything Protocol
{{Short description|Software testing protocol}}
{{For|the network tunnel driver|TUN/TAP}}
{{More citations needed|date=October 2017}}
The Test Anything Protocol (TAP) is a protocol for communicating between test logic, called a TAP producer, and a test harness in a language-agnostic way. Originally developed for unit testing of the Perl interpreter in 1987, producers and parsers are now available for many development platforms.
History
TAP was created for the first version of the Perl programming language (released in 1987), as part of Perl's core test harness ({{samp|t/TEST}}). The Test::Harness
module was written by Tim Bunce and Andreas König to allow Perl module authors to take advantage of TAP. It became the de facto standard for Perl testing.{{cite web|url=https://nnc3.com/mags/LM10/Magazine/Archive/2005/61/076-080_perl/article.html|title=A Perl toolbox for regression tests : Testing Tools|website=Nnc3.com|accessdate=27 October 2017}}{{cite web|url=http://www.linux-magazine.com/Issues/2016/187/Perl-Print-Test|title=Print as Print Can » Linux Magazine|first=Mike|last=Schilli|website=Linux Magazine|accessdate=27 October 2017}}{{cite web
|url=https://perlmaven.com/tap-test-anything-protocol
|title=TAP - Test Anything Protocol
|last=Szabo
|first=Gabor
|website=Perl Maven
|access-date=2019-08-07
}}
Development of TAP, including standardization of the protocol, writing of test producers and consumers, and evangelizing the language is coordinated at the TestAnything website.{{cite web |url=http://www.testanything.org/ |title=The Test Anything Protocol website|website=TestAnything |accessdate= February 17, 2025}}
As a protocol which is agnostic of programming language, TAP unit testing libraries expanded beyond their Perl roots and have been developed for various languages and systems such as PostgreSQL,{{cite web
|url=https://medium.com/engineering-on-the-incline/unit-testing-postgres-with-pgtap-af09ec42795
|title=Unit testing Postgres with pgTAP
|last=McClive
|first=Simon
|date=2017-09-21
|website=Medium
|access-date=2019-08-07
}} MySQL,{{cite web
|url=https://www.databasejournal.com/features/mysql/testing-your-mysql-stored-procedures-with-mytap.html
|title=Testing Your MySQL Stored Procedures with MyTAP
|last=Gravelle
|first=Rob
|date=2012-08-13
|website=Database Journal
|access-date=2019-08-07
|url=https://node-tap.org/
|title=Node Tap
|website=Node Tap
|access-date=2019-08-07
}} and other implementations listed on the project site. A TAP C library is included as part of the FreeBSD Unix distribution and is used in the system's regression test suite.{{cite web
|url=https://www.freebsd.org/cgi/man.cgi?query=tap&sektion=3
|title=TAP(3) manual page
|website=FreeBSD
|access-date=2019-08-07 }}
Specification
A formal specification for this protocol exists in the TAP::Spec::Parser
and TAP::Parser::Grammar
modules. The behavior of the Test::Harness
module is the de facto TAP standard implementation, along with a writeup of the specification on TestAnything.org.
A project to produce an IETF standard for TAP was initiated in August 2008, at YAPC::Europe 2008.{{update inline|date=February 2025}}
Examples
Here's an example of TAP's general format:
1..48
ok 1 Description # Directive
- Diagnostic
....
ok 47 Description
ok 48 Description
For example, a test file's output might look like:
1..4
ok 1 - Input file opened
not ok 2 - First line of the input valid.
More output from test 2. There can be
arbitrary number of lines for any output
so long as there is at least some kind
of whitespace at beginning of line.
ok 3 - Read the rest of the file
- TAP meta information
not ok 4 - Summarized correctly # TODO: not written yet
See also
- {{Annotated link|xUnit}}
References
{{Reflist}}