Files
tldr/pages.zh/common/go-test.md

28 lines
585 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# go test
> 测试 Go 包(文件必须以 `_test.go` 结尾)。
> 更多信息:<https://pkg.go.dev/cmd/go#hdr-Testing_flags>。
- 测试当前目录中的包:
`go test`
- [v] 详细测试当前目录中的包:
`go test -v`
- 测试当前目录及所有子目录中的包(注意 `...`
`go test -v ./...`
- 测试当前目录中的包并运行所有基准测试:
`go test -v -bench .`
- 测试当前目录中的包并运行所有基准测试,持续 50 秒:
`go test -v -bench . -benchtime {{50s}}`
- 进行覆盖率分析的测试:
`go test -cover`