July 2017
Beginner to intermediate
358 pages
10h 54m
English
Code coverage is an excellent metric to ensure that the code you are writing has adequate coverage.
The most simplistic way of getting a readout of test coverage is to execute our tests with the -cover option:
go test -cover ./...
If we run this against our example code in the root folder of our example code we will see the following output:
$go test -cover ./...? github.com/building-microservices-with-go/chapter4 [no test files]ok github.com/building-microservices-with-go/chapter4/data 0.017s coverage: 20.0% of statementsok github.com/building-microservices-with-go/chapter4/features 0.018s coverage: 0.0% of statements [no tests to run]ok github.com/building-microservices-with-go/chapter4/handlers 0.018s coverage: 100.0% of ...
Read now
Unlock full access