go test ./...Run tests for all packages in the module. Useful in Go CLI workflows.
go test patterns for package tests, focused runs, benchmarks, fuzzing, coverage, JSON output, and CI-friendly test workflows.
Test Basics commands and patterns for the Go command.
go test ./...Run tests for all packages in the module. Useful in Go CLI workflows.
go test -v ./...Print each test as it runs. Useful in Go CLI workflows.
go test -run TestHTTP ./...Run only tests whose names match a regexp. Useful in Go CLI workflows.
go test -count=1 ./...Force tests to run instead of using cached results. Useful in Go CLI workflows.
go test -failfast ./...Abort package test execution after the first failure. Useful in Go CLI workflows.
Benchmarks commands and patterns for the Go command.
go test -bench=. ./...Run benchmarks matching a regexp. Useful in Go CLI workflows.
go test -bench=. -benchtime=3s ./...Control how long each benchmark runs. Useful in Go CLI workflows.
go test -bench=. -benchmem ./...Include memory allocation stats in benchmark output. Useful in Go CLI workflows.
go test -run=^$ -bench=BenchmarkParse .Benchmark current package only. Useful in Go CLI workflows.
Coverage commands and patterns for the Go command.
Measure coverage for multiple packages while testing one package set.
go test -coverpkg=./... ./...Measure coverage for multiple packages while testing one package set. Useful in Go CLI workflows.
go test -coverprofile=coverage.out ./...Write a cover profile for later analysis. Useful in Go CLI workflows.
go tool cover -func=coverage.outShow function-by-function coverage from a profile. Useful in Go CLI workflows.
go tool cover -html=coverage.outRender an HTML coverage report. Useful in Go CLI workflows.
Fuzzing commands and patterns for the Go command.
go test -fuzz=FuzzParseRun or continue fuzzing for a matching fuzz target. Useful in Go CLI workflows.
go test -fuzz=FuzzParse -fuzztime=30sRun fuzzing for a bounded amount of time. Useful in Go CLI workflows.
go test -run=FuzzParseRun only seed inputs in a fuzz test. Useful in Go CLI workflows.
CI and Machine Output commands and patterns for the Go command.
go test -json ./...Generate machine-readable test events. Useful in Go CLI workflows.
go test -shuffle=on ./...Detect order-dependent tests by shuffling. Useful in Go CLI workflows.
go test -timeout=2m ./...Fail tests that exceed a timeout. Useful in Go CLI workflows.
go test -parallel=4 ./...Set max parallel tests in a package. Useful in Go CLI workflows.