|
|
5 yıl önce | |
|---|---|---|
| .. | ||
| internal | 5 yıl önce | |
| testjson | 5 yıl önce | |
| .gitignore | 5 yıl önce | |
| .golangci.yml | 5 yıl önce | |
| .goreleaser.yml | 5 yıl önce | |
| BUILD | 5 yıl önce | |
| Gopkg.toml | 5 yıl önce | |
| LICENSE | 5 yıl önce | |
| README.md | 5 yıl önce | |
| dobi.yaml | 5 yıl önce | |
| exitcode.go | 5 yıl önce | |
| flags.go | 5 yıl önce | |
| go.mod | 5 yıl önce | |
| go.sum | 5 yıl önce | |
| handler.go | 5 yıl önce | |
| main.go | 5 yıl önce | |
gotestsum runs tests, prints friendly test output and a summary of the test run. Requires Go 1.10+.
Download a binary from releases, or get the
source with go get gotest.tools/gotestsum (you may need to run dep ensure).
gotestsum works by running go test --json ./... and reading the JSON
output.
Set a format with the --format flag or the GOTESTSUM_FORMAT environment
variable.
gotestsum --format short-verbose
Supported formats:
dots - output one character per test.short (default) - output a line for each test package.standard-quiet - the default go test format.short-verbose - output a line for each test and package.standard-verbose - the standard go test -v format.Have a suggestion for some other format? Please open an issue!
A summary of the test run is printed after the test output.
DONE 101 tests[, 3 skipped][, 2 failures][, 1 error] in 0.103s
The summary includes:
To disable parts of the summary use --no-summary section.
Example: hide skipped tests in the summary
gotestsum --no-summary=skipped
Example: hide failed and skipped
gotestsum --no-summary=skipped,failed
Example: hide output in the summary, only print names of failed and skipped tests and errors
gotestsum --no-summary=output
When the --junitfile flag or GOTESTSUM_JUNITFILE environment variable are set
to a file path gotestsum will write a test report, in JUnit XML format, to the file.
This file can be used to integrate with CI systems.
gotestsum --junitfile unit-tests.xml
When the --jsonfile flag or GOTESTSUM_JSONFILE environment variable are set
to a file path gotestsum will write a line-delimited JSON file with all the
test2json
output that was written by go test --json. This file can be used to compare test
runs, or find flaky tests.
gotestsum --jsonfile test-output.log
go test commandBy default gotestsum runs tests using the command go test --json ./.... You
can change the command with positional arguments after a --. You can change just the
test directory value (which defaults to ./...) by setting the TEST_DIRECTORY
environment variable.
You can use --debug to echo the command before it is run.
Example: set build tags
gotestsum -- -tags=integration ./...
Example: run tests in a single package
gotestsum -- ./io/http
Example: enable coverage
gotestsum -- -coverprofile=cover.out ./...
Example: run a script instead of go test
gotestsum --raw-command -- ./scripts/run_tests.sh
Note: when using --raw-command you must ensure that the stdout produced by
the script only contains the test2json output. Any stderr produced by the script
will be considered an error (this behaviour is necessary because package build errors
are only reported by writting to stderr, not the test2json stdout). Any stderr
produced by tests is not considered an error (it will be in the test2json stdout).
Example: using TEST_DIRECTORY
TEST_DIRECTORY=./io/http gotestsum
filewatcher will automatically set the
TEST_DIRECTORY environment variable which makes it easy to integrate
gotestsum.
Example: run tests for a package when any file in that package is saved
filewatcher gotestsum
This package is heavily influenced by the pytest test runner for python.