https://github.com/hedzr/assert
a set of assertion helpers for unit/bench testing in golang
https://github.com/hedzr/assert
assert assertions golang golang-library testing testing-library
Last synced: 4 months ago
JSON representation
a set of assertion helpers for unit/bench testing in golang
- Host: GitHub
- URL: https://github.com/hedzr/assert
- Owner: hedzr
- License: mit
- Created: 2020-10-27T17:37:43.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-11-12T09:22:29.000Z (over 4 years ago)
- Last Synced: 2025-01-15T01:08:12.785Z (6 months ago)
- Topics: assert, assertions, golang, golang-library, testing, testing-library
- Language: Go
- Homepage: https://hedzr.github.io/golang/testing/golang-assert-1/
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# assert

[](https://github.com/hedzr/assert/releases)
[](https://pkg.go.dev/github.com/hedzr/assert)
[](https://godoc.org/github.com/hedzr/assert)
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fhedzr%2Fassert?ref=badge_shield)
[](https://goreportcard.com/report/github.com/hedzr/assert)
[](https://coveralls.io/github/hedzr/assert?branch=master)`assert` provides a set of assertion helpers for unit/bench testing in golang.
`assert` is inspired by these projects:
-
-
- assert, mock, suite ...### improvements
- Can be used with both unit test and bench test.
- Most of conventiional assertions:
- Equal, NotEqual, EqualTrue, EqualFalse
- Nil, NotNil
- Error, NoError
- PanicMatches: test for the function which might throw a panic
- Match, NotMatch: compares a value with regexp test
- Fresh coding in go 1.13~1.15 and later.### Short guide
```go
package some_testimport (
"github.com/hedzr/assert"
"testing"
)type Person struct {
Name string
Age int
}func TestEqual(t *testing.T) {
expected := []*Person{{"Alec", 20}, {"Bob", 21}, {"Sally", 22}}
actual := []*Person{{"Alex", 20}, {"Bob", 22}, {"Sally", 22}}
assert.NotEqual(t, expected, actual)assert.Equal(t, actual, actual)
}func TestEqualTrue(t *testing.T) {
assert.EqualTrue(t, true)
assert.EqualFalse(t, false)
}
```### LICENSE
MIT