2021-06-16 23:07:59 -03:00
|
|
|
# go test
|
|
|
|
|
|
|
|
> Tests Go packages (files have to end with `_test.go`).
|
2024-11-03 12:18:25 -08:00
|
|
|
> More information: <https://pkg.go.dev/cmd/go#hdr-Testing_flags>.
|
2021-06-16 23:07:59 -03:00
|
|
|
|
|
|
|
- Test the package found in the current directory:
|
|
|
|
|
|
|
|
`go test`
|
|
|
|
|
|
|
|
- [v]erbosely test the package in the current directory:
|
|
|
|
|
|
|
|
`go test -v`
|
|
|
|
|
|
|
|
- Test the packages in the current directory and all subdirectories (note the `...`):
|
|
|
|
|
|
|
|
`go test -v ./...`
|
|
|
|
|
|
|
|
- Test the package in the current directory and run all benchmarks:
|
|
|
|
|
|
|
|
`go test -v -bench .`
|
|
|
|
|
|
|
|
- Test the package in the current directory and run all benchmarks for 50 seconds:
|
|
|
|
|
|
|
|
`go test -v -bench . -benchtime {{50s}}`
|
2022-03-07 13:04:55 +01:00
|
|
|
|
|
|
|
- Test the package with coverage analysis:
|
|
|
|
|
|
|
|
`go test -cover`
|