trial alternatives and similar packages
Based on the "Testing Frameworks" category.
Alternatively, view trial 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
Access the most powerful time series database as a service
Do you think we are missing an alternative of trial or a related project?
Popular Comparisons
README
Trial

A simple assertion library for go. Also see schema for easier JSON Schema testing.
Motivation
go-test is fine. We do not need big testing frameworks for most projects. One thing its lacking though is simple assertions and ability to implement simple helpers as it does not allow us to skip test logs.
Trial gives us th.Error(t testingT, skip int, msgs ...interface{})
allowing to skip callers to implement helpers with nice logging.
For most uses, the trial/assert
package is enough, giving us the most basic assertions needed with nice error messages.
trial/assert Usage
Simple equals
import "github.com/jgroeneveld/trial/assert"
assert.Equal(t, 1, 2)
Output:
unit_test.go:42: Not equal:
Expected: 1
Actual: 2
Additional arguments to overwrite the message
assert.Equal(t, 1, 2, "numbers dont match for %q", "my param")
Output:
unit_test.go:42: numbers dont match for "my param":
Expected: 1
Actual: 2
Type problems are made clear
assert.Equal(t, 1, int64(1))
unit_test.go:42: Not equal:
Expected: 1
Actual: 1
Types: Expected:int, Actual:int64
See [example/example_test.go](example/example_test.go) for more.
Supported Assertions
Basic assertions
Equal(expected, actual, msgf...)
MustBeEqual(expected, actual, msgf...)
NotEqual(expected, actual, msgf...)
MustNotBeEqual(expected, actual, msgf...)
DeepEqual(expected, actual, msgf...)
MustBeDeepEqual(expected, actual, msgf...)
True(expression bool, msgf...)
MustBeTrue(expression bool, msgf...)
False(expression bool, msgf...)
MustBeFalse(expression bool, msgf...)
Nil(expression, msgf...)
MustBeNil(expression, msgf...)
NotNil(expression, msgf...)
MustNotBeNil(expression, msgf...)
JSON Schema assertions
JSONSchema(reader, matcher, msgf...)
MustMatchJSONSchema(reader, matcher, msgf...)
Writing your own assertions
th
can be used to write simple own assertions. This for example gives you a wrapper for schema.MatchJSON to have simple JSON schema assertions in your tests:
func AssertJSONSchema(t *testing.T, matcher schema.Matcher, r io.Reader) {
err := schema.MatchJSON(matcher, r)
if err != nil {
th.Error(t, 1, err.Error())
}
}
func MustMatchJSONSchema(t *testing.T, matcher schema.Matcher, r io.Reader) {
err := schema.MatchJSON(matcher, r)
if err != nil {
th.Error(t, 1, err.Error())
t.FailNow()
}
}