https://github.com/pkg/expect
A simple assertion library that you probably shouldn't use.
https://github.com/pkg/expect
ffs oh-no uugh
Last synced: about 2 months ago
JSON representation
A simple assertion library that you probably shouldn't use.
- Host: GitHub
- URL: https://github.com/pkg/expect
- Owner: pkg
- License: bsd-2-clause
- Created: 2019-12-07T23:56:29.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-09T05:39:38.000Z (over 5 years ago)
- Last Synced: 2025-03-26T13:45:23.346Z (2 months ago)
- Topics: ffs, oh-no, uugh
- Language: Go
- Homepage:
- Size: 2.93 KB
- Stars: 132
- Watchers: 6
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# expect [](https://travis-ci.org/pkg/expect) [](http://godoc.org/github.com/pkg/expect) [](https://goreportcard.com/report/github.com/pkg/expect) [](https://sourcegraph.com/github.com/pkg/expect?badge)
A simple assertion library that you probably shouldn't use.
## Quickstart
Package `expect` contains various test assertion helpers.
```go
func TestOpenFile(t *testing.T) {
f, err := os.Open("notfound")
expect.Nil(err)
err = f.Close()
expect.True(err == nil)
}
```
`expect` helpers can be called from any function called from the main testing goroutine.
```bash
% go test
--- FAIL: TestOpenFile (0.00s)
check_test.go:12: expected: , got: open notfound: no such file or directory
```Consult the [documentation](https://godoc.org/github.com/pkg/expect) for more information.
## How does this work?

## No, seriously, how does this work?
`*testing.T` is recovered dynamically from the call stack. Read the [blog post](https://dave.cheney.net/2019/12/08/dynamically-scoped-variables-in-go).
## License
BSD-2-Clause