Documentation ¶
Overview ¶
Ginkgo is a BDD-style testing framework for Golang
The godoc documentation describes Ginkgo's API. More comprehensive documentation (with examples!) is available at http://onsi.github.io/ginkgo/
Ginkgo's preferred matcher library is [Gomega](http://github.com/pivotal/gumshoe/repos/gomega)
Ginkgo on Github: http://github.com/pivotal/gumshoe/repos/ginkgo
Ginkgo is MIT-Licensed
Index ¶
- Constants
- Variables
- func AfterEach(body interface{}, timeout ...float64) bool
- func BeforeEach(body interface{}, timeout ...float64) bool
- func Context(text string, body func()) bool
- func Describe(text string, body func()) bool
- func FContext(text string, body func()) bool
- func FDescribe(text string, body func()) bool
- func FIt(text string, body interface{}, timeout ...float64) bool
- func FMeasure(text string, body func(Benchmarker), samples int) bool
- func Fail(message string, callerSkip ...int)
- func It(text string, body interface{}, timeout ...float64) bool
- func JustBeforeEach(body interface{}, timeout ...float64) bool
- func Measure(text string, body func(Benchmarker), samples int) bool
- func PContext(text string, body func()) bool
- func PDescribe(text string, body func()) bool
- func PIt(text string, _ ...interface{}) bool
- func PMeasure(text string, _ ...interface{}) bool
- func RunSpecs(t GinkgoTestingT, description string) bool
- func RunSpecsWithCustomReporters(t GinkgoTestingT, description string, specReporters []Reporter) bool
- func RunSpecsWithDefaultAndCustomReporters(t GinkgoTestingT, description string, specReporters []Reporter) bool
- func XContext(text string, body func()) bool
- func XDescribe(text string, body func()) bool
- func XIt(text string, _ ...interface{}) bool
- func XMeasure(text string, _ ...interface{}) bool
- type Benchmarker
- type Done
- type GinkgoTInterface
- type GinkgoTestDescription
- type GinkgoTestingT
- type Reporter
Constants ¶
const GINKGO_VERSION = config.VERSION
Variables ¶
var GinkgoWriter io.Writer
GinkgoWriter implements an io.Writer When running in verbose mode any writes to GinkgoWriter will be immediately printed to stdout
When not in verbose mode, GinkgoWriter will buffer any writes and flush them to screen only if the current test fails. In this mode, GinkgoWriter is truncated between tests.
Functions ¶
func AfterEach ¶
AfterEach blocks are run after It blocks. When multiple AfterEach blocks are defined in nested Describe and Context blocks the innermost AfterEach blocks are run first.
Like It blocks, BeforeEach blocks can be made asynchronous by providing a body function that accepts a Done channel
func BeforeEach ¶
BeforeEach blocks are run before It blocks. When multiple BeforeEach blocks are defined in nested Describe and Context blocks the outermost BeforeEach blocks are run first.
Like It blocks, BeforeEach blocks can be made asynchronous by providing a body function that accepts a Done channel
func Context ¶
Context blocks allow you to organize your specs. A Context block can contain any number of BeforeEach, AfterEach, JustBeforeEach, It, and Measurement blocks.
In addition you can nest Describe and Context blocks. Describe and Context blocks are functionally equivalent. The difference is purely semantic -- you typical Describe the behavior of an object or method and, within that Describe, outline a number of Contexts.
func Describe ¶
Describe blocks allow you to organize your specs. A Describe block can contain any number of BeforeEach, AfterEach, JustBeforeEach, It, and Measurement blocks.
In addition you can nest Describe and Context blocks. Describe and Context blocks are functionally equivalent. The difference is purely semantic -- you typical Describe the behavior of an object or method and, within that Describe, outline a number of Contexts.
func FMeasure ¶
func FMeasure(text string, body func(Benchmarker), samples int) bool
You can focus individual Measures using FMeasure
func Fail ¶
Fail notifies Ginkgo that the current spec has failed. (Gomega will call Fail for you automatically when an assertion fails.)
func It ¶
It blocks contain your test code and assertions. You cannot nest any other Ginkgo blocks within an It block.
Ginkgo will normally run It blocks synchronously. To perform asynchronous tests, pass a function that accepts a Done channel. When you do this, you can alos provide an optional timeout.
func JustBeforeEach ¶
JustBeforeEach blocks are run before It blocks but *after* all BeforeEach blocks. For more details, read the [documentation](http://onsi.github.io/ginkgo/#separating_creation_and_configuration_)
Like It blocks, BeforeEach blocks can be made asynchronous by providing a body function that accepts a Done channel
func Measure ¶
func Measure(text string, body func(Benchmarker), samples int) bool
Measure blocks run the passed in body function repeatedly (determined by the samples argument) and accumulate metrics provided to the Benchmarker by the body function.
func RunSpecs ¶
func RunSpecs(t GinkgoTestingT, description string) bool
RunSpecs is the entry point for the Ginkgo test runner. You must call this within a Go Test... function.
To bootstrap a test suite you can use the Ginkgo CLI:
ginkgo bootstrap
func RunSpecsWithCustomReporters ¶
func RunSpecsWithCustomReporters(t GinkgoTestingT, description string, specReporters []Reporter) bool
To run your tests with your custom reporter(s) (and *not* Ginkgo's default reporter), replace RunSpecs() with this method.
func RunSpecsWithDefaultAndCustomReporters ¶
func RunSpecsWithDefaultAndCustomReporters(t GinkgoTestingT, description string, specReporters []Reporter) bool
To run your tests with Ginkgo's default reporter and your custom reporter(s), replace RunSpecs() with this method.
Types ¶
type Benchmarker ¶
type Benchmarker interface { Time(name string, body func(), info ...interface{}) (elapsedTime time.Duration) RecordValue(name string, value float64, info ...interface{}) }
Measurement tests receive a Benchmarker.
You use the Time() function to time how long the passed in body function takes to run You use the RecordValue() function to track arbitrary numerical measurements. The optional info argument is passed to the test reporter and can be used, alongside a custom reporter, to provide the measurement data with context.
See http://onsi.github.io/ginkgo/#benchmark_tests for more details
type Done ¶
type Done chan<- interface{}
Asynchronous specs given a channel of the Done type. You must close (or send to) the channel to tell Ginkgo that your async test is done.
type GinkgoTInterface ¶
type GinkgoTInterface interface { Fail() Error(args ...interface{}) Errorf(format string, args ...interface{}) FailNow() Fatal(args ...interface{}) Fatalf(format string, args ...interface{}) Log(args ...interface{}) Logf(format string, args ...interface{}) Failed() bool Parallel() Skip(args ...interface{}) Skipf(format string, args ...interface{}) SkipNow() Skipped() bool }
The interface returned by GinkgoT()
func GinkgoT ¶
func GinkgoT(optionalOffset ...int) GinkgoTInterface
Some matcher libraries or legacy codebases require a *testing.T GinkgoT implements an interface analogous to *testing.T and can be used if the library in question accepts *testing.T through an interface
For example, with testify: assert.Equal(GinkgoT(), 123, 123, "they should be equal")
GinkgoT() takes an optional offset argument that can be used to get the correct line number associated with the failure.
type GinkgoTestDescription ¶
type GinkgoTestDescription struct { ComponentTexts []string FullTestText string TestText string IsMeasurement bool FileName string LineNumber int }
GinkgoTestDescription represents the information about the current running test returned by CurrentGinkgoTest
ComponentTexts: a list of all texts for the Describes & Contexts leading up to the current test FullTestText: a concatenation of ComponentTexts TestText: the text in the actual It or Measure node IsMeasurement: true if the current test is a measurement FileName: the name of the file containing the current test LineNumber: the line number for the current test
func CurrentGinkgoTestDescription ¶
func CurrentGinkgoTestDescription() GinkgoTestDescription
CurrentGinkgoTestDescripton returns information about the current running test.
type GinkgoTestingT ¶
type GinkgoTestingT interface {
Fail()
}
The interface by which Ginkgo receives *testing.T
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Ginkgo accepts a number of configuration options.
|
Ginkgo accepts a number of configuration options. |
The Ginkgo CLI
|
The Ginkgo CLI |
aggregator
Aggregator is a reporter used by the Ginkgo CLI to aggregate and present parallel test output as one coherent stream.
|
Aggregator is a reporter used by the Ginkgo CLI to aggregate and present parallel test output as one coherent stream. |
support/fsnotify
Package fsnotify implements filesystem notification.
|
Package fsnotify implements filesystem notification. |
Ginkgo's Default Reporter
|
Ginkgo's Default Reporter |
thirdparty
|
|
gomocktestreporter
The gomocktestreporter package provides a Ginkgo friendly implementation of [Gomock's](https://code.google.com/p/gomock/) `TestReporter` interface.
|
The gomocktestreporter package provides a Ginkgo friendly implementation of [Gomock's](https://code.google.com/p/gomock/) `TestReporter` interface. |