Code coverage measures which portions of program code a test suite executes. Go reports coverage alongside test results, helping reveal functions or implementations that tests do not exercise. section 1.2.4 section 6.3.4
Use Go's built-in commands to inspect coverage at increasing levels of detail:
- Run go test -cover to print the percentage of covered statements. section 1.2.4 section 6.3.4
- Run go test -v -cover -coverprofile mycover.out to save formatted coverage data. section 6.3.4
- Run go tool cover -html mycover.out to visualize covered and uncovered code in a browser. section 6.3.4
Uncovered functions
An application with foo, bar, and baz functions has tests for foo and bar only. Running the tests reports 66.7% statement coverage, making the untested portion visible for follow-up work. section 6.3.4
Figure 6.5 Our test coverage in the browser
Open the browser visualization to inspect test coverage across the application in a single view. section 6.3.4













