The Test Anything Protocol (TAP) is a protocol to allow communication between
unit test
In computer programming, unit testing is a software testing method by which individual units of source code—sets of one or more computer program modules together with associated control data, usage procedures, and operating procedures&m ...
s and a
test harness In software testing, a test harness or automated test framework is a collection of software and test data configured to test a program unit by running it under varying conditions and monitoring its behavior and outputs. It has two main parts: the t ...
. It allows individual tests (TAP producers) to communicate test results to the testing harness in a
language-agnostic
Language-agnostic programming or scripting (also called language-neutral, language-independent, or cross-language) is a software paradigm in which no particular language is promoted.
In introductory instruction, the term refers to teaching princip ...
way. Originally developed for unit testing of the
Perl
Perl is a family of two High-level programming language, high-level, General-purpose programming language, general-purpose, Interpreter (computing), interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it ...
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
Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offic ...
(released in 1987), as part of the Perl's core test harness (
t/TEST
). The
Test::Harness
module
Module, modular and modularity may refer to the concept of modularity. They may also refer to:
Computing and engineering
* Modular design, the engineering discipline of designing complex devices using separately designed sub-components
* Mo ...
was written by
Tim Bunce and
Andreas König
Andreas ( el, Ἀνδρέας) is a name usually given to males in Austria, Greece, Cyprus, Denmark, Armenia, Estonia, Ethiopia, Eritrea, Finland, Flanders, Germany, Norway, Sweden, Switzerland, Romania, the Netherlands, and Indonesia. The name ...
to allow Perl module authors to take advantage of TAP. It became the ''de facto'' standard for Perl testing.
Development of TAP, including standardization of the protocol, writing of test producers and consumers, and evangelizing the language is coordinated at the TestAnything website.
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
PostgreSQL (, ), also known as Postgres, is a free and open-source relational database management system (RDBMS) emphasizing extensibility and SQL compliance. It was originally named POSTGRES, referring to its origins as a successor to the In ...
,
MySQL
MySQL () is an open-source relational database management system (RDBMS). Its name is a combination of "My", the name of co-founder Michael Widenius's daughter My, and "SQL", the acronym for Structured Query Language. A relational database ...
,
JavaScript
JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
and other implementations listed on the project site.
A TAP C library is included as part of the
FreeBSD
FreeBSD is a free and open-source Unix-like operating system descended from the Berkeley Software Distribution (BSD), which was based on Research Unix. The first version of FreeBSD was released in 1993. In 2005, FreeBSD was the most popular ...
Unix distribution and is used in the system's regression test suite.
[
]
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 https://testanything.org.
A project to produce an
IETF
The Internet Engineering Task Force (IETF) is a standards organization for the Internet and is responsible for the technical standards that make up the Internet protocol suite (TCP/IP). It has no formal membership roster or requirements and ...
standard for TAP was initiated in August 2008, at
YAPC
Yet Another Perl Conference (YAPC), from 2016–2019 called The Perl Conference (TPC), from 2020 on The Perl and Raku Conference, is a series of conferences discussing the Perl programming language, usually organized under the auspices of The Per ...
::Europe 2008.
Usage 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
*
xUnit
xUnit is the collective name for several unit testing frameworks that derive their structure and functionality from Smalltalk's SUnit. ''SUnit'', designed by Kent Beck in 1998, was written in a highly structured object-oriented style, which l ...
References
{{Reflist
External links
Site dedicated to the discussion, development and promotion of TAP
Perl
Computer file formats
Unit testing