November 2018
Intermediate to advanced
346 pages
8h 12m
English
In Go, test coverage is calculated by adding a -cover flag along with a call to a regular call to go test. As this only works for one package at a time, I find this inconvenient. So we are going to use a tool that recursively calculates test coverage for all the packages in a directory tree. This tool is called package-coverage and is available from GitHub (https://github.com/corsc/go-tools/tree/master/package-coverage).
To calculate the coverage using package-coverage, we use the following commands:
$ cd $GOPATH/src/github.com/PacktPublishing/Hands-On-Dependency-Injection-in-Go/ch08/$ export ACME_CONFIG=$GOPATH/src/github.com/PacktPublishing/Hands-On-Dependency-Injection-in-Go/config.json$ package-coverage -a -prefix ...
Read now
Unlock full access