tt

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2018 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package tt supports table-driven tests with little boilerplate.

See the test case for this package for example usage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Test

func Test(t T, fn *FnToTest, tests Table)

Test tests a function against test cases.

Types

type Case

type Case struct {
	// contains filtered or unexported fields
}

Case represents a test case. It is created by the C function, and offers setters that augment and return itself; those calls can be chained like C(...).Rets(...).

func Args

func Args(args ...interface{}) *Case

Args returns a new Case with the given arguments.

func (*Case) Rets

func (c *Case) Rets(matchers ...interface{}) *Case

Rets modifies the test case so that it requires the return values to match the given values. It returns the receiver.

type FnToTest

type FnToTest struct {
	// contains filtered or unexported fields
}

FnToTest describes a function to test.

func Fn

func Fn(name string, body interface{}) *FnToTest

Fn makes a new FnToTest with the given function name and body.

func (*FnToTest) ArgsFmt

func (fn *FnToTest) ArgsFmt(s string) *FnToTest

ArgsFmt sets the string for formatting arguments in test error messages, and return fn itself.

func (*FnToTest) RetsFmt

func (fn *FnToTest) RetsFmt(s string) *FnToTest

RetsFmt sets the string for formatting return values in test error messages, and return fn itself.

type T

type T interface {
	Errorf(format string, args ...interface{})
}

T is the interface for accessing testing.T.

type Table

type Table []*Case

Table represents a test table.

Jump to

Keyboard shortcuts

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