https://github.com/kkyr/assert
An assertion utility for Go tests
https://github.com/kkyr/assert
assertions go golang testing
Last synced: 5 months ago
JSON representation
An assertion utility for Go tests
- Host: GitHub
- URL: https://github.com/kkyr/assert
- Owner: kkyr
- License: apache-2.0
- Created: 2022-08-22T21:47:36.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-31T12:40:50.000Z (almost 4 years ago)
- Last Synced: 2023-07-27T22:17:24.805Z (almost 3 years ago)
- Topics: assertions, go, golang, testing
- Language: Go
- Homepage:
- Size: 23.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# assert [](https://github.com/kkyr/assert/tags) [](https://goreportcard.com/report/github.com/kkyr/assert) [](https://coveralls.io/github/kkyr/assert?branch=main)
assert is a Go library that helps you make assertions in tests, printing a human-readable report of the differences between two values in assertions that fail.
## Installation
```shell
$ go get github.com/kkyr/assert@latest
```
## Usage
```go
package person_test
import (
"testing"
"github.com/kkyr/assert"
)
func TestPerson(t *testing.T) {
assert := assert.New(t)
want := []string{"John", "Jim"}
got := []string{"John", "Joe"}
assert.Field("Names").Equal(want, got)
// Output:
// --- FAIL: TestPerson (0.00s)
// person_test.go:15: Names: (-want, +got):
// []string{
// "John",
// - "Jim",
// + "Joe",
// }
}
```
## Documentation
[](https://pkg.go.dev/github.com/kkyr/assert?tab=doc)