What is a .tap file?
text/plain
TAP (Test Anything Protocol) is a line-based plain-text format for reporting test results. A stream declares a plan such as `1..12` and then emits one `ok` or `not ok` line per test, optionally with a description, a `# SKIP` or `# TODO` directive, and an indented YAML block carrying diagnostic detail. It is deliberately simple enough that a test runner in any language can emit it and a harness can parse it line by line.
How to use a .tap file
Use an example .tap file to test TAP consumers, CI result parsers, and format converters — checking that the declared plan matches the number of assertions, that skipped and TODO directives are classified separately from failures, and that diagnostic YAML blocks survive the round trip.
Download example .tap files
- TAP — Plan First, All PassingThe canonical TAP shape: a version line, a leading plan, then six passing assertions in order. Anything a TAP consumer does with a real stream it must do with this one first.
- TAP — Trailing PlanThe same stream with the plan at the end, which is what a harness emits when it does not know the test count up front. A consumer that requires a leading plan rejects a perfectly valid stream.
- TAP — Failures with YAML DiagnosticsTwo failing assertions, each followed by an indented YAML diagnostic block carrying the expected and actual values and a file/line location. The block is where every useful failure message in TAP lives, and it is the part naive line-based parsers throw away.
- TAP — Bail Out Mid-RunA run abandoned after the third assertion with a Bail out! line, leaving five of the planned eight assertions unreported. The run is a failure even though only one assertion said not ok, and a consumer must not report 2/3 passing as a 67% pass rate.
- TAP — Comments and Diagnostic LinesFree-form # comment lines interleaved with assertions, including a trailing summary block. Comments carry no result and must never shift assertion numbering, which is exactly what a parser counting lines instead of ok/not ok tokens gets wrong.
- TAP — Plan Count Does Not MatchEvery assertion in this stream says ok, but the plan promised ten and only eight arrived — the signature of a runner that crashed after its last reported assertion. A consumer that only counts not ok lines calls this a clean pass.
- TAP — SKIP DirectivesTwo assertions marked # SKIP with a reason, alongside a genuine failure. Skipped assertions are written as ok, so counting ok lines reports 5 passes when only 3 tests actually ran.
- TAP — TODO DirectivesTwo failing assertions marked # TODO, meaning they are known-unfinished work rather than regressions. A TODO failure must not fail the run, so a consumer that treats every not ok as a build breaker turns this green run red.
and 4 more in the library.