Skip to content

Instantly share code, notes, and snippets.

@nucleartide
Last active November 16, 2015 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nucleartide/9af9576ba5ed85738153 to your computer and use it in GitHub Desktop.
Save nucleartide/9af9576ba5ed85738153 to your computer and use it in GitHub Desktop.

just looking through golang's testing category and making conclusions about what to use.

conclusions

  1. go's testing package is good for starters. libs provide more expressive APIs.
  1. use testify for assertions.
  2. your mileage may vary for supertest-style HTTP assertions.
  3. investigate ginkgo and testify suites.
  4. mocking is there if you need it.

assertion libs

  • opinion: bmizerany/assert is simple, stretchr/testify/assert is feature rich.
  • Testify
    • A sacred extension to the standard go testing package.
  • assert
    • Basic Assertion Library used along side native go testing, with building blocks for custom assertions
  • assert
    • Asserts to Go testing

matcher assertions

  • opinion: unnecessary abstraction. also unmaintained.
  • Hamcrest
    • fluent framework for declarative Matcher objects that, when applied to input values, produce self-describing results.

HTTP assertions

  • opinion: testify seems to have HTTP assertions.
  • frisby
    • a REST API testing framework
  • restit
    • A Go micro framework to help writing RESTful API integration test.
  • Testify
    • A sacred extension to the standard go testing package.

file watching (equivalent to mocha --watch)

  • opinion: cool. don't need it though.
  • bro
    • Watch files in directory and run tests for them

test frameworks (mostly BDD)

  • opinion: quality varies. most seem to choose an assertion lib, syntax, and reporter for you, so they lack extensibility. (though it's easy enough to change syntax - just assign to a newly named var).
  • opinion: ginkgo seems well thought out.
  • opinion: testify struct suites are also nice and object-oriented.
  • ginkgo
    • BDD Testing Framework for Go
  • goblin
    • Mocha like testing framework for Go
  • gocheck
    • A more advanced testing framework alternative to gotest.
  • GoConvey
    • BDD-style framework with web UI and live reload
  • godog
    • Cucumber or Behat like BDD framework for Go.
  • GoSpec
    • BDD-style testing framework for the Go programming language.
  • gospecify
    • This provides a BDD syntax for testing your Go code. It should be familiar to anybody who has used libraries such as rspec.
  • Testify
    • A sacred extension to the standard go testing package.
  • zen and mao are lightweight options, though are obviously missing things

mocking, faking, spying, etc.

  • opinion: DB mocks could be useful for speeding up DB tests. testify seems to have Called methods.
  • Testify
    • A sacred extension to the standard go testing package.
  • counterfeiter
    • Tool for generating self-contained mock objects
  • go-sqlmock
    • Mock SQL driver for testing database interactions
  • go-txdb
    • Single transaction based database driver mainly for testing purposes.
  • gomock
    • Mocking framework for the Go programming language.
  • mockhttp
    • Mock object for Go http.ResponseWriter

mutation testing, fuzzing, delta-debugging, reducing, shrinking, etc.

  • opinion: interesting. don't need it though.
  • go-mutesting
    • Mutation testing for Go source code
  • go-fuzz
    • A randomized testing system
  • gofuzz
    • A library for populating go objects with random values
  • gogenerate
    • A Scalacheck-like library for Go
  • Tavor
    • A generic fuzzing and delta-debugging framework
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment