Go: tests with HTML coverage report

Tests result viewed as an HTML page.
go test ./...
as an example project, I am using a popular cobra package (spf13/cobra)
go test -cover ./...
test coverage result
go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
a detailed coverage result
go tool cover -html=coverage.out
a detailed coverage report viewed as an HTML report
go test -covermode=count -coverprofile=coverage.out
GO=go
GOCOVER=$(GO) tool cover
.PHONY: test/cover
test/cover:
$(GOTEST) -v -coverprofile=coverage.out ./...
$(GOCOVER) -func=coverage.out
$(GOCOVER) -html=coverage.out

Software Engineer. Go and Python. Learning Rust. https://kenanbek.github.io/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store