I created one sample go project and created a unit test cases for the same (In Linux environment, go1.3 version)
When i ran go test
the output would be
PASS
ok supported_db 0.201s
And i tried to perform code coverage for whole application by using go test -cover
command it shows
go tool: no such tool "cover"; to install:
go get code.google.com/p/go.tools/cmd/cover
Also i checked the coverage while running a specific test case by running go test -cover CouchDB_test.go
command it shows
ok command-line-arguments 0.158s coverage: 0.0% of statements
please help me to run code coverage in golang.
It helped me
Just add -coverpkg=./...
option if tests are in sub folders:
go test ./... -v -coverpkg=./...
Try first:
go test -coverprofile=coverage.out
I then run, to see the result:
go tool cover -html=coverage.out
If the 1.3 version was installed through an upgrade of 1.1, 1.2, ..., you can try, as in issue 110:
I solved this by completely removing $GOPATH/src/code.google.com/p/go.tools and install cover again:
go get golang.org/x/tools/cmd/cover
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With