Documentation ¶
Overview ¶
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 ¶
- type T
- func (t *T) AutoPlan()
- func (t *T) Check(function interface{}, description string)
- func (t *T) Count() int
- func (t *T) Diagnostic(message string)
- func (t *T) Diagnosticf(format string, a ...interface{})
- func (t *T) Fail(description string)
- func (t *T) Header(testCount int)
- func (t *T) Ok(test bool, description string)
- func (t *T) Pass(description string)
- func (t *T) Skip(count int, description string)
- func (t *T) Todo() *T
- func (t *T) YAML(message interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 (*T) AutoPlan ¶
func (t *T) AutoPlan()
AutoPlan generates a test plan based on the number of tests that were run.
func (*T) Check ¶
Check runs randomized tests against a function just as "testing/quick.Check" does. Success or failure generate appropriate TAP output.
func (*T) Diagnostic ¶
Diagnostic generates a diagnostic from the message, which may span multiple lines.
func (*T) Diagnosticf ¶
Diagnosticf generates a diagnostic from the format string and arguments, which may span multiple lines.
func (*T) Fail ¶
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 ¶
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) Pass ¶
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.