Documentation ¶
Overview ¶
Package gunit provides "testing" package hooks and convenience functions for writing tests in an xUnit style. See the README file and the examples folder for examples.
Index ¶
- func Run(fixture interface{}, t *testing.T)
- func RunSequential(fixture interface{}, t *testing.T)
- type Fixture
- func (this *Fixture) Assert(condition bool, messages ...string) bool
- func (this *Fixture) AssertDeepEqual(expected, actual interface{}) bool
- func (this *Fixture) AssertEqual(expected, actual interface{}) bool
- func (this *Fixture) AssertSprintEqual(expected, actual interface{}) bool
- func (this *Fixture) AssertSprintfEqual(expected, actual interface{}, format string) bool
- func (this *Fixture) Error(args ...interface{})
- func (this *Fixture) Errorf(f string, args ...interface{})
- func (this *Fixture) Failed() bool
- func (this *Fixture) Name() string
- func (this *Fixture) Print(a ...interface{})
- func (this *Fixture) Printf(format string, a ...interface{})
- func (this *Fixture) Println(a ...interface{})
- func (this *Fixture) So(actual interface{}, assert assertion, expected ...interface{}) bool
- func (this *Fixture) Write(p []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run receives an instance of a struct that embeds *Fixture. The struct definition may include Setup*, Teardown*, and Test* methods which will be run as an xUnit-style test fixture.
func RunSequential ¶
RunSequential, like Run receives an instance of a struct that embeds *Fixture. The fixture is run in much the same way, except that it will not be run in parallel with other fixtures in the same package.
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. The Fixture manages an instance of *testing.T. Certain methods defined herein merely forward to calls on the *testing.T:
- Fixture.Error(...) ----> *testing.T.Error
- Fixture.Errorf(...) ---> *testing.T.Errorf
- Fixture.Print(...) ----> *testing.T.Log or fmt.Print
- Fixture.Printf(...) ---> *testing.T.Logf or fmt.Printf
- Fixture.Println(...) --> *testing.T.Log or fmt.Println
- Fixture.Failed() ------> *testing.T.Failed()
- Fixture.fail() --------> *testing.T.Fail()
We don't use these methods much, preferring instead to lean heavily on Fixture.So and the rich set of should-style assertions provided at github.com/smartystreets/assertions/should
func (*Fixture) Assert ¶
Assert tests a boolean which, if not true, marks the current test case as failed and prints the provided message.