Announcing Ginkgo and Gomega: BDD-Style Testing for Golang

October 9, 2013 Onsi Fakhouri

I’m happy to announce that Ginkgo, a BDD-style testing framework for Go, and its preferred matcher library Gomega are ready for public release. There’s a comprehensive feature list, on the GitHub READMEs and both projects have extensive documentation written up (Ginkgo and Gomega).

Here’s a quick taste of what a Ginkgo & Gomega test looks like, there are many more samples in the documentation:

Describe("ScoreKeeper", func() {
    var scoreKeeper *ScoreKeeper

    BeforeEach(func() {
        var err error
        scoreKeeper, err = NewScoreKeeper("Denver Broncos")

    It("should have a starting score of 0", func() {

    Context("when a touchdown is scored", func() {
        BeforeEach(func() {

        It("should increment the score", func() {

        It("should update the scoring player's stats", func() {

And here’s (a screenshot of) the output of go test:

Ginkgo Test Runner

So, why write Ginkgo?

Google’s Golang treats testing as a first-class citizen. Go has builtin support for writing and running unit tests in the Xunit style. Go, however, does not come with an assertion/matcher library. Nor does it provide any of the higher-level testing constructs that those in the BDD school of testing have grown fond of. Go’s authors have made it clear that these omissions are intentional.

After spending some time writing tests the Go way, I quickly came to miss all the things about BDD that make BDD-style testing so expressive and productive: descriptive tests that can act as effective documentation, simple shared test set up and teardown, nested contexts, etc… Thankfully, writing a solid full-featured BDD testing framework and matcher library for Go turned out to be relatively straightforward: a testament to Go’s flexibility!

Ginkgo and Gomega are heavily influenced by Cedar (BDD for Objective-C) and Jasmine (BDD for Javascript). If you’re familiar with either you’ll feel right at home with Ginkgo.

So Go forth and BDD! I’m looking forward to your pull requests – especially for any new Gomega matchers that you might find useful.

Ginkgo Gomega

About the Author


More Content by Onsi Fakhouri
Pivotal to Ring the Bell at the New York Stock Exchange on Oct 29
Pivotal to Ring the Bell at the New York Stock Exchange on Oct 29

Pivotal and NYSE Euronext are uniting to drive innovation and productivity in the world of Hadoop and Big D...

Case Study: Analyzing Retail/e-Commerce 318x Faster on HAWQ +MADlib
Case Study: Analyzing Retail/e-Commerce 318x Faster on HAWQ +MADlib

Retailers are using big data to improve business outcomes, and one of our customers has shown that Pivotal ...

Enter curious. Exit smarter.

Register Now