How to understand bazel coverage coverage.dat file?

Viewed 1362

Hello I have been searching the internet a lot but I cannot find an easy way to generate a html coverage file for our golang project but at least I can get a coverage.dat file which looks like this

mode: set
path/foo.go:13.58,15.2 1 1
path/foo.go:17.56,19.2 1 1

I couldn't even find the document for this file, what do these numbers mean? It looks like line number but not quite.

My Bazel version is 2.2.0

1 Answers

It looks like line number but not quite

fields are: name.go:line.column,line.column numberOfStatements count

Source

You can generate html with next command:

# Generate coverage profile using Cover tool
> go test -coverprofile=coverage.out ./.. 
# To analyze coverage via a browser
> go tool cover -html=coverage.out

Last command will generate html file under /tmp/coverXXXXX/coverage.html

Related