Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit

* Fixed assertion IsNil() failing when passing a nil slice

* Fixed assertion IsNil() failing when passing a nil slice

* Fixed assertion IsNil() failing when passing a nil slice

* Expand Nil checks to every builtin go type

Git stats


Failed to load latest commit information.
Latest commit message
Commit time
September 18, 2013 19:34
October 17, 2013 01:45
May 29, 2015 02:40
November 1, 2016 20:39
October 17, 2013 00:25
August 24, 2020 16:34
December 3, 2013 20:19


Build Status Go Reportcard GoDoc License Release

A Mocha like BDD testing framework written in Go that requires no additional dependencies. Requires no extensive documentation nor complicated steps to get it running.

Why Goblin?

Inspired by the flexibility and simplicity of Node BDD and frustrated by the rigorousness of Go way of testing, we wanted to bring a new tool to write self-describing and comprehensive code.

What do I get with it?

  • Run tests as usual with go test
  • Colorful reports and beautiful syntax
  • Preserve the exact same syntax and behaviour as Node's Mocha
  • Nest as many Describe and It blocks as you want
  • Use Before, BeforeEach, After and AfterEach for setup and teardown your tests
  • No need to remember confusing parameters in Describe and It blocks
  • Use a declarative and expressive language to write your tests
  • Plug different assertion libraries
  • Gomega (supported so far)
  • Skip your tests the same way as you would do in Mocha
  • Automatic terminal support for colored outputs
  • Two line setup is all you need to get up running

How do I use it?

Since go test is not currently extensive, you will have to hook Goblin to it. You do that by adding a single test method in your test file. All your goblin tests will be implemented inside this function.

package foobar

import (
    . ""

func Test(t *testing.T) {
    g := Goblin(t)
    g.Describe("Numbers", func() {
        // Passing Test
        g.It("Should add two numbers ", func() {
        // Failing Test
        g.It("Should match equal numbers", func() {
        // Pending Test
        g.It("Should substract two numbers")
        // Excluded Test
        g.Xit("Should add two numbers ", func() {

Ouput will be something like:

Nice and easy, right?

Can I do asynchronous tests?

Yes! Goblin will help you to test asynchronous things, like goroutines, etc. You just need to add a done parameter to the handler function of your It. This handler function should be called when your test passes.

  g.Describe("Numbers", func() {
      g.It("Should add two numbers asynchronously", func(done Done) {
          go func() {

Goblin will wait for the done call, a Fail call or any false assertion.

How do I use it with Gomega?

Gomega is a nice assertion framework. But it doesn't provide a nice way to hook it to testing frameworks. It should just panic instead of requiring a fail function. There is an issue about that here. While this is being discussed and hopefully fixed, the way to use Gomega with Goblin is:

package foobar

import (
    goblin ""
    . ""

func Test(t *testing.T) {
    g := goblin.Goblin(t)

    //special hook for gomega
    RegisterFailHandler(func(m string, _ { g.Fail(m) })

    g.Describe("lala", func() {
        g.It("lslslslsls", func() {


How do I run specific tests?

If$REGES is supplied to the go test command then only tests that match the supplied regex will run


We do have a couple of issues pending. Feel free to contribute and send us PRs (with tests please 😄).

Special Thanks

Special thanks to Leandro Reox (Leitan) for the goblin logo.