Last Updated: February 25, 2016
·
924
· kazark

Use Ginkgo with Gomega for specs in Go

If you are someone who favors spec-style testing, you may enjoy Ginkgo for describing your code and Gomega for make assertions about it. They are written by the same author and they play nicely both with each other and with Go's built in testing framework (you can do go test to run the tests).

var _ = Describe('Fooing', func() { // Ginkgo
    Context('When bar', func() { // Ginkgo
        BeforeEach(func() { // Ginkgo
            ...
        })
        It('Should foobar!', func() { // Ginkgo
           Expect(...).To(Equal(...)) // Gomega
        })
})