Name: onsi-ginkgo
Owner: OpenShift
Description: BDD Testing Framework for Go
Forked from: onsi/ginkgo
Created: 2017-09-29 19:16:59.0
Updated: 2018-02-28 20:15:02.0
Pushed: 2018-03-21 17:12:23.0
Homepage: http://onsi.github.io/ginkgo/
Size: 4979
Language: Go
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Jump to the docs to learn more. To start rolling your Ginkgo tests now keep reading!
If you have a question, comment, bug report, feature request, etc. please open a GitHub issue.
Ginkgo uses Go's testing
package and can live alongside your existing testing
tests. It's easy to bootstrap and start writing your first tests
Structure your BDD-style tests expressively:
Describe
and Context
container blocksBeforeEach
and AfterEach
blocks for setup and teardownIt
blocks that hold your assertionsJustBeforeEach
blocks that separate creation from configuration (also known as the subject action pattern).BeforeSuite
and AfterSuite
blocks 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=N
runs your tests in N
parallel processes and print out coherent output in realtimeginkgo -cover
runs your tests using Golang's code coverage toolginkgo convert
converts an XUnit-style testing
package to a Ginkgo-style packageginkgo -focus="REGEXP"
and ginkgo -skip="REGEXP"
allow you to specify a subset of tests to run via regular expressionginkgo -r
runs all tests suites under the current directoryginkgo -v
prints out identifying information for each tests just before it runsAnd much more: run ginkgo help
for details!
The ginkgo
CLI is convenient, but purely optional – Ginkgo works just fine with go test
ginkgo watch
watches 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 Ginkgo Completions
.
Completions for VSCode: just use VSCode's extension installer to install vscode-ginkgo
.
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:
Ginkgo is best paired with Gomega. Learn more about Gomega here
Agouti allows you run WebDriver integration tests. Learn more about Agouti here
You'll need Golang v1.3+ (Ubuntu users: you probably have Golang v1.0 – you'll need to upgrade!)
et github.com/onsi/ginkgo/ginkgo # installs the ginkgo CLI
et github.com/onsi/gomega # fetches the matcher library
ath/to/package/you/want/to/test
go bootstrap # set up a new ginkgo suite
go generate # will create a sample test file. edit this file and add your tests then...
est # to run your tests
go # also runs your tests
Of course, I heartily recommend Ginkgo and Gomega. Both packages are seeing heavy, daily, production use on a number of projects and boast a mature and comprehensive feature-set.
With that said, it's great to know what your options are :)
Testing is a first class citizen in Golang, however Go's built-in testing primitives are somewhat limited: The testing package provides basic XUnit style tests and no assertion library.
A number of matcher libraries have been written to augment Go's built-in XUnit style tests. Here are two that have gained traction:
You can also use Ginkgo's matcher library Gomega in XUnit style tests
There are a handful of BDD-style testing frameworks written for Golang. Here are a few:
Finally, @shageman has put together a comprehensive comparison of golang testing libraries.
Go explore!
Ginkgo is MIT-Licensed
Since Ginkgo tests also internal packages, when you fork, you'll have to replace imports with your repository.
Use before_pr.sh
for that
After you finished your changes and before you push your pull request, use after_pr.sh
to revert those changes