Ginkgo is a BDD-style Go testing framework built to help you efficiently write expressive and comprehensive tests. It is best paired with the Gomega matcher library but is designed to be matcher-agnostic.
- Ginkgo uses Go’s
testingpackage and can live alongside your existing
testingtests. It’s easy to bootstrap and start writing your first tests
- Structure your BDD-style tests expressively:
AfterEachblocks for setup and teardown
Specifyblocks that hold your assertions
JustBeforeEachblocks that separate creation from configuration (also known as the subject action pattern).
AfterSuiteblocks to prep for and cleanup after a suite.
- A comprehensive test runner that lets you:
ginkgo: a command line interface with plenty of handy command line arguments for running your tests and generating test files. Here are a few choice examples:
ginkgo -nodes=Nruns your tests in
Nparallel processes and print out coherent output in realtime
ginkgo -coverruns your tests using Go’s code coverage tool
ginkgo convertconverts an XUnit-style
testingpackage to a Ginkgo-style package
ginkgo -skip="REGEXP"allow you to specify a subset of tests to run via regular expression
ginkgo -rruns all tests suites under the current directory
ginkgo -vprints out identifying information for each tests just before it runs
ginkgo helpfor details!The
ginkgoCLI is convenient, but purely optional — Ginkgo works just fine with
ginkgo watchwatches packages and their dependencies for changes, then reruns tests. Run tests immediately as you develop!
- Built-in support for testing asynchronicity
- Built-in support for benchmarking your code. Control the number of benchmark samples as you gather runtimes and other, arbitrary, bits of numerical information about your code.
- Completions for Sublime Text: just use Package Control to install
- Completions for VSCode: just use VSCode’s extension installer to install
- Straightforward support for third-party testing libraries such as Gomock and Testify. Check out the docs for details.
- A modular architecture that lets you easily:
- Write custom reporters (for example, Ginkgo comes with a JUnit XML reporter and a TeamCity reporter).
- Adapt an existing matcher library (or write your own!) to work with Ginkgo