Documentation ¶
Overview ¶
Package gunit provides "testing" package hooks and convenience functions for writing tests in an xUnit style. NOTE: Only some of the exported names in this package are meant to be referenced by users of this package:
- Fixture // (as an embedded field on your xUnit-style struct) - Fixture.So(...) // (as a convenient assertion method: So(expected, should.Equal, actual)) - Fixture.Ok(...) // (as a convenient boolean assertion method: Ok(condition, optionalMessage)) - Fixture.Error(...) // (works just like *testing.T.Error(...)) - Fixture.Errorf(...) // (works just like *testing.T.Errorf(...)) - Fixture.Print(...) // (works just like fmt.Print) - Fixture.Printf(...) // (works just like fmt.Printf) - Fixture.Println(...) // (works just like fmt.Println)
The rest are called from code generated by the command at github.com/smartystreets/gunit/gunit. Please see the README file and the examples folder for examples.
Index ¶
- func FormatFailureContext(lineNumber int, code string) string
- func Validate(checksum string)
- type Fixture
- func (self *Fixture) Error(args ...interface{})
- func (self *Fixture) Errorf(format string, args ...interface{})
- func (self *Fixture) Finalize()
- func (self *Fixture) Ok(condition bool, messages ...string)
- func (self *Fixture) Print(a ...interface{}) (n int, err error)
- func (self *Fixture) Printf(format string, a ...interface{}) (n int, err error)
- func (self *Fixture) Println(a ...interface{}) (n int, err error)
- func (self *Fixture) So(actual interface{}, ...) bool
- type TT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatFailureContext ¶
Types ¶
type Fixture ¶
type Fixture struct {
// contains filtered or unexported fields
}
Fixture keeps track of test status (failed, passed, skipped) and handles custom logging for xUnit style tests as an embedded field.
func NewFixture ¶
NewFixture is called by generated code.
func (*Fixture) Print ¶
Print is analogous to fmt.Print and is ideal for printing in the middle of a test case.
func (*Fixture) Printf ¶
Printf is analogous to fmt.Printf and is ideal for printing in the middle of a test case.
func (*Fixture) Println ¶
Println is analogous to fmt.Println and is ideal for printing in the middle of a test case.
func (*Fixture) So ¶
func (self *Fixture) So(actual interface{}, assert func(actual interface{}, expected ...interface{}) string, expected ...interface{}) bool
So is a convenience method for reporting assertion failure messages, say from the assertion functions found in github.com/smartystreets/assertions/should. Example: self.So(actual, should.Equal, expected)
Directories ¶
Path | Synopsis |
---|---|
gunit generates testing functions by scanning for xunit-style struct-based fixtures that implement gunit test fixtures (see github.com/smartystreets/gunit).
|
gunit generates testing functions by scanning for xunit-style struct-based fixtures that implement gunit test fixtures (see github.com/smartystreets/gunit). |