Use `go test` to compile and run package tests, then inspect which tests passed or failed. Put tests in files ending `_test.go`; Go excludes those files from normal application builds. Test functions begin with `Test` and receive a `*testing.T`, which can report failures with `t.Errorf`. Run `go test` for the current package or `go test ./...` to include packages in subdirectories. section 1.2.4
Catch a string-reversal bug
A byte-by-byte `reverseName` can appear correct with simple input but fail on a multibyte character. A test compares its result with an expected string and reports a mismatch through `t.Errorf`. Reverse a `[]rune` instead, then rerun `go test` to check the fix. This turns an easy-to-miss manual-testing mistake into a regression test. section 1.2.4
func reverseNameFixed(name string) string {
reversed := make([]rune, 0)
runes := []rune(name)
for i := len(runes) - 1; i >= 0; i-- {
reversed = append(reversed, runes[i])
}
return string(reversed)
}
The corrected function converts the input to runes before reversing it, rather than reversing its bytes. section 1.2.4
To find gaps in testing, run `go test -v -cover`. The reported statement-coverage percentage gives a quick overview, not a requirement to reach 100%. For a browser view, run `go test -v -cover -coverprofile mycover.out`, followed by `go tool cover -html mycover.out`. The saved profile helps locate code that the tests did not exercise. section 6.3.4
The same command runs benchmarks stored in `_test.go` files: use `go test -bench=.` for all matching benchmarks or, for example, `go test -bench=BenchmarkBubbleSort10$` for one. Benchmark functions receive a `*testing.B` and use `b.N` to control repeated work. Use `-benchtime` to change the minimum run time and `-benchmem` to include allocation data. section 6.4
Compare sorting costs
A Bubble Sort benchmark suite tests integer slices of several lengths and reports runs and time per operation. As written, its helper generates a slice once and sorts that same slice repeatedly; keep that setup in mind when interpreting the measurements. section 6.4



