gocovmerge
takes the results from multiple go test -coverprofile
runs and merges them into one profile.
To install the latest version, run:
go install github.com/ja7ad/gocovmerge/cmd/gocovmerge@latest
This will install the gocovmerge
binary into your $GOPATH/bin
or $GOBIN
directory.
gocovmerge [coverprofiles...]
coverprofiles...
: One or more Go coverage profile files (output fromgo test -coverprofile=coverage.out
).
gocovmerge
takes the source coverprofiles as arguments and outputs a merged version of the files to standard out.
Note: You can only merge profiles that were generated from the same source code. If there are source lines that overlap or do not merge, the process will exit with an error code.
-
Run tests with coverage in different packages or configurations:
go test -coverprofile=unit_coverage.txt ./... go test -coverprofile=integration_coverage.txt ./...
-
Merge the coverage profiles:
gocovmerge unit_coverage.txt integration_coverage.txt > merged_coverage.txt
-
Use the merged coverage profile as needed (e.g., for coverage reporting tools).
See LICENSE.