goblin alternatives and similar packages
Based on the "Testing Frameworks" category.
Alternatively, view goblin alternatives based on common mentions on social networks and blogs.
-
Testify
A toolkit with common assertions and mocks that plays nicely with the standard library -
GoConvey
Go testing in the browser. Integrates with `go test`. Write behavioral tests in Go. -
gnomock
Test your code without writing mocks with ephemeral Docker containers ๐ฆ Setup popular services with just a couple lines of code โฑ๏ธ No bash, no yaml, only code ๐ป -
go-vcr
Record and replay your HTTP interactions for fast, deterministic and accurate tests -
testfixtures
Ruby on Rails like test fixtures for Go. Write tests against a real database -
embedded-postgres
Run a real Postgres database locally on Linux, OSX or Windows as part of another Go application or test -
gotest.tools
A collection of packages to augment the go testing package and support common patterns. -
testza
Full-featured test framework for Go! Assertions, fuzzing, input testing, output capturing, and much more! ๐ -
go-testdeep
Extremely flexible golang deep comparison, extends the go testing package, tests HTTP APIs and provides tests suite -
dbcleaner
Clean database for testing, inspired by database_cleaner for Ruby -
GoSpec
Testing framework for Go. Allows writing self-documenting tests/specifications, and executes them concurrently and safely isolated. [UNMAINTAINED] -
jsonassert
A Go test assertion library for verifying that two representations of JSON are semantically equal -
testcase
testcase is an opinionated testing framework to support test driven design. -
assert
:exclamation:Basic Assertion Library used along side native go testing, with building blocks for custom assertions -
gogiven
gogiven - BDD testing framework for go that generates readable output directly from source code -
schema
Quick and easy expression matching for JSON schemas used in requests and responses
Collect and Analyze Billions of Data Points in Real Time
Do you think we are missing an alternative of goblin or a related project?
Popular Comparisons
README
Goblin
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
andIt
blocks as you want - Use
Before
,BeforeEach
,After
andAfterEach
for setup and teardown your tests - No need to remember confusing parameters in
Describe
andIt
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 (
"testing"
. "github.com/franela/goblin"
)
func Test(t *testing.T) {
g := Goblin(t)
g.Describe("Numbers", func() {
// Passing Test
g.It("Should add two numbers ", func() {
g.Assert(1+1).Equal(2)
})
// Failing Test
g.It("Should match equal numbers", func() {
g.Assert(2).Equal(4)
})
// Pending Test
g.It("Should substract two numbers")
// Excluded Test
g.Xit("Should add two numbers ", func() {
g.Assert(3+1).Equal(4)
})
})
}
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() {
g.Assert(1+1).Equal(2)
done()
}()
})
})
...
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 (
"testing"
goblin "github.com/franela/goblin"
. "github.com/onsi/gomega"
)
func Test(t *testing.T) {
g := goblin.Goblin(t)
//special hook for gomega
RegisterFailHandler(func(m string, _ ...int) { g.Fail(m) })
g.Describe("lala", func() {
g.It("lslslslsls", func() {
Expect(1).To(Equal(10))
})
})
}
FAQ
How do I run specific tests?
If -goblin.run=$REGES
is supplied to the go test
command then only tests that match the supplied regex will run
Contributing
We do have a couple of issues pending. Feel free to contribute and send us PRs (with tests please :smile:).
Special Thanks
Special thanks to Leandro Reox (Leitan) for the goblin logo.
*Note that all licence references and agreements mentioned in the goblin README section above
are relevant to that project's source code only.