assert alternatives and similar packages
Based on the "Testing Frameworks" category.
Alternatively, view assert 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. -
dockertest
Write better integration tests! Dockertest helps you boot up ephermal docker images for your Go tests with minimal work. -
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. -
gogiven
gogiven - BDD testing framework for go that generates readable output directly from source code
InfluxDB - Power Real-Time Data Analytics at Scale
Do you think we are missing an alternative of assert or a related project?
Popular Comparisons
README
Package assert
Package assert is a Basic Assertion library used along side native go testing
Installation
Use go get.
go get github.com/go-playground/assert
Then import the assert package into your own code.
import . "github.com/go-playground/assert/v2"
Usage and documentation
Please see http://godoc.org/github.com/go-playground/assert for detailed usage docs.
Example:
package whatever
import (
"errors"
"testing"
. "github.com/go-playground/assert/v2"
)
func AssertCustomErrorHandler(t testing.TB, errs map[string]string, key, expected string) {
val, ok := errs[key]
// using EqualSkip and NotEqualSkip as building blocks for my custom Assert function
EqualSkip(t, 2, ok, true)
NotEqualSkip(t, 2, val, nil)
EqualSkip(t, 2, val, expected)
}
func TestEqual(t *testing.T) {
// error comes from your package/library
err := errors.New("my error")
NotEqual(t, err, nil)
Equal(t, err.Error(), "my error")
err = nil
Equal(t, err, nil)
fn := func() {
panic("omg omg omg!")
}
PanicMatches(t, func() { fn() }, "omg omg omg!")
PanicMatches(t, func() { panic("omg omg omg!") }, "omg omg omg!")
// errs would have come from your package/library
errs := map[string]string{}
errs["Name"] = "User Name Invalid"
errs["Email"] = "User Email Invalid"
AssertCustomErrorHandler(t, errs, "Name", "User Name Invalid")
AssertCustomErrorHandler(t, errs, "Email", "User Email Invalid")
}
How to Contribute
Make a PR.
I strongly encourage everyone whom creates a usefull custom assertion function to contribute them and help make this package even better.
License
Distributed under MIT License, please see license file in code for more details.
*Note that all licence references and agreements mentioned in the assert README section above
are relevant to that project's source code only.