package module
v0.0.0-...-629fa40 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2017 License: Unlicense Imports: 6 Imported by: 243


Test Anything Protocol for Go

The Test Anything Protocol ("TAP") is a text-based interface between tests and a test harness. This package helps Go to generate TAP output.

Read the full package documentation



Package tap provides support for automated Test Anything Protocol ("TAP") tests in Go. For example:

package main

import "github.com/mndrix/tap-go"

func main() {
	t := tap.New()
	t.Ok(true, "first test")
	t.Ok(true, "second test")

generates the following output

TAP version 13
ok 1 - first test
ok 2 - second test



This section is empty.


This section is empty.


This section is empty.


type T

type T struct {

	// TODO toggles the TODO directive for Ok, Fail, Pass, and similar.
	TODO bool

	// Writer indicates where TAP output should be sent.  The default is os.Stdout.
	Writer io.Writer
	// contains filtered or unexported fields

T is a type to encapsulate test state. Methods on this type generate TAP output.

func New

func New() *T

New creates a new Tap value

func (*T) AutoPlan

func (t *T) AutoPlan()

AutoPlan generates a test plan based on the number of tests that were run.

func (*T) Check

func (t *T) Check(function interface{}, description string)

Check runs randomized tests against a function just as "testing/quick.Check" does. Success or failure generate appropriate TAP output.

func (*T) Count

func (t *T) Count() int

Count returns the number of tests completed so far.

func (*T) Diagnostic

func (t *T) Diagnostic(message string)

Diagnostic generates a diagnostic from the message, which may span multiple lines.

func (*T) Diagnosticf

func (t *T) Diagnosticf(format string, a ...interface{})

Diagnosticf generates a diagnostic from the format string and arguments, which may span multiple lines.

func (*T) Fail

func (t *T) Fail(description string)

Fail indicates that a test has failed. This is typically only used when the logic is too complex to fit naturally into an Ok() call.

func (*T) Header

func (t *T) Header(testCount int)

Header displays a TAP header including version number and expected number of tests to run. For an unknown number of tests, set testCount to zero (in which case the plan is not written); this is useful with AutoPlan.

func (*T) Ok

func (t *T) Ok(test bool, description string)

Ok generates TAP output indicating whether a test passed or failed.

func (*T) Pass

func (t *T) Pass(description string)

Pass indicates that a test has passed. This is typically only used when the logic is too complex to fit naturally into an Ok() call.

func (*T) Skip

func (t *T) Skip(count int, description string)

Skip indicates that a test has been skipped.

func (*T) Todo

func (t *T) Todo() *T

Todo returns copy of the test-state with TODO set.

func (*T) YAML

func (t *T) YAML(message interface{}) error

YAML generates a YAML block from the message.


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL