tap-go – github.com/mndrix/tap-go Index | Files | Directories

package tap

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

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.Header(2)
	t.Ok(true, "first test")
	t.Ok(true, "second test")
}

generates the following output

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

Index

Types

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.

Source Files

tap.go yaml_json.go

Directories

PathSynopsis
test
test/auto
test/check
test/diagnostic
test/failing
test/known
test/skip
test/todo
test/writer
test/yaml
Version
v0.0.0-20171203230836-629fa407e90b (latest)
Published
Dec 3, 2017
Platform
js/wasm
Imports
6 packages
Last checked
2 months ago

Tools for package owners.