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 ¶
- Constants
- Variables
- func Run(fixture interface{}, t *testing.T, options ...option)
- type Fixture
- func (f *Fixture) Assert(condition bool, messages ...string) bool
- func (f *Fixture) AssertDeepEqual(expected, actual interface{}) bool
- func (f *Fixture) AssertEqual(expected, actual interface{}) bool
- func (f *Fixture) AssertSprintEqual(expected, actual interface{}) bool
- func (f *Fixture) AssertSprintfEqual(expected, actual interface{}, format string) bool
- func (f *Fixture) Errorf(format string, args ...interface{})
- func (f *Fixture) Fail()
- func (f *Fixture) Failed() bool
- func (f *Fixture) FatalStop(args ...interface{})
- func (f *Fixture) FatalfStop(format string, args ...interface{})
- func (f *Fixture) GetLogger() *Logger
- func (f *Fixture) Name() string
- func (f *Fixture) Run(name string, test func(fixture *Fixture))
- func (f *Fixture) SkipNow()
- func (f *Fixture) So(actual interface{}, assert assertion, expected ...interface{}) bool
- func (f *Fixture) T() TestingT
- func (f *Fixture) Write(p []byte) (int, error)
- type Logger
- type TestingT
Constants ¶
const ( Test = "FixtureTestName" Package = "FixturePackageName" Title = "FixtureTestTitle" RequestApi = "FixtureRequestApi" )
const FixtureParallel = "FixtureParallel"
Variables ¶
var Options singleton
Functions ¶
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 itself and it's *testing.T control the test flow.
func (*Fixture) Assert ¶
Assert tests a boolean which, if not true, marks the current test case as failed and prints the provided message.
func (*Fixture) AssertDeepEqual ¶
func (*Fixture) AssertEqual ¶
func (*Fixture) AssertSprintEqual ¶
func (*Fixture) AssertSprintfEqual ¶
func (*Fixture) FatalStop ¶ added in v1.1.0
func (f *Fixture) FatalStop(args ...interface{})
FatalStop stop the test right now and the tests behind it will be skipped in SequentialTestCases mode.
func (*Fixture) FatalfStop ¶ added in v1.1.0
func (*Fixture) Run ¶
Run is analogous to *testing.T.Run and allows for running subtests from test fixture methods (such as for table-driven tests).
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}