1 ## Code Coverage Reports for Golang Applications ##
3 This document covers how to generate HTML Code Coverage Reports for
6 #### Generate a test executable which calls your main()
9 $ go test -c -covermode=count -coverpkg ./...
12 #### Run the generated application to produce a new coverage report
15 $ ./sms.test -test.run "^TestMain$" -test.coverprofile=coverage.cov
18 #### Run your unit tests to produce their coverage report
21 $ go test -test.covermode=count -test.coverprofile=unit.out ./...
24 #### Merge the two coverage Reports
27 $ go get github.com/wadey/gocovmerge
28 $ gocovmerge unit.out coverage.cov > all.out
31 #### Generate HTML Report
34 $ go tool cover -html all.out -o coverage.html
37 #### Generate Function Report
40 $ go tool cover -func all.out