Closed
Description
Description
Now in 1.10 when go test -cover
supports multiple packages, I would expect it to print out a percentage for all packages (including those missing tests).
And for go test -coverprofile
, I would expect all packages to be included in the calculated total.
Currently only packages that have at least one test (can be a *_test.go
with only the package
declaration) is included, see pkg2
below.
What version of Go are you using (go version
)?
go version go1.10 linux/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env
)?
Linux, amd64
What did you do?
go test ./... -cover
go test ./... -coverprofile cover.out; go tool cover -func cover.out
What did you expect to see?
? path/to/pkg1 0.001s coverage: 0.0% of statements [no test files]
ok path/to/pkg2 0.019s coverage: 0.0% of statements [no tests to run]
ok path/to/pkg3 0.371s coverage: 100.0% of statements
path/to/pkg1/pkg1.go:5: String 0.0%
path/to/pkg2/pkg2.go:5: String 0.0%
path/to/pkg3/pkg3.go:5: String 100.0%
total: (statements) 33.3%
What did you see instead?
? path/to/pkg1 [no test files]
ok path/to/pkg2 0.019s coverage: 0.0% of statements [no tests to run]
ok path/to/pkg3 0.371s coverage: 100.0% of statements
path/to/pkg2/pkg2.go:5: String 0.0%
path/to/pkg3/pkg3.go:5: String 100.0%
total: (statements) 50.0%