Coverage

When writing tests, it's often important to know how much of your actual code the tests cover. This is often called a coverage test.


> go test -coverprofile=coverage.out

// Output:
PASS
coverage: 50.0% of statements
ok      ./math 2.073s
                        

Now you can present the results in a web browser:


> go tool cover -html=coverage.out
                        
coverage.go