Increase code coverage of Go projects
The key challenge with large code bases with low test coverage is to prioritize which sections of code to test first.
The standard coverage tools tell about the code coverage percentage and what is covered and uncovered however it doesn't give an input on which functions to cover first and what will be the impact of covering them.
This tool addresses the challenge by providing the sorted list of functions to cover and the impact associated with covering it.
To get a local copy up and running follow these simple steps.
You'll need Go installed to use this tool. Here is the installation instructions for Go.
Via go get
go get -u github.com/gojek/go-coverage
Generate the coverage profile for your Go codebase, usually done via
go test ./... -coverprofile=coverage.out
go-coverage -f coverage.out --line-filter 10
go-coverage -f coverage.out --line-filter 10 --trim
+-------------------------+-------------------------------------+-----------------+--------+
| FILE | FUNCTION | UNCOVERED LINES | IMPACT |
+-------------------------+-------------------------------------+-----------------+--------+
| ...ice/config/config.go | RadiusForClosestDriverByServicetype | 26 | 1.9 |
| ...ice/config/config.go | RadiusForServicetype | 26 | 1.9 |
| ...ice/config/config.go | AliceDriverLimit | 26 | 1.9 |
| ...ice/config/config.go | ConsumerDriverLimitByServicetype | 26 | 1.9 |
| .../service/handlers.go | findDriver | 19 | 1.4 |
| ...ice/extern/driver.go | driverAllocationStatusFromAPI | 19 | 1.4 |
| .../service/handlers.go | updateDriverVehicleTags | 18 | 1.3 |
| ...ice/config/config.go | ConsumerDriverLimit | 14 | 1.0 |
| ...vice/service/cron.go | startCrons | 14 | 1.0 |
| ...ice/config/config.go | RadiusForVehicleType | 13 | 0.9 |
| ...ice/config/config.go | matchVehicleType | 12 | 0.9 |
| ...rvice/service/api.go | startServer | 11 | 0.8 |
+-------------------------+-------------------------------------+-----------------+--------+
go-coverage -f coverage.out --exclude ".*config.*" --line-filter 10 --trim
+-------------------------+-------------------------------+-----------------+--------+
| FILE | FUNCTION | UNCOVERED LINES | IMPACT |
+-------------------------+-------------------------------+-----------------+--------+
| .../service/handlers.go | findDriver | 19 | 1.4 |
| ...ice/extern/driver.go | driverAllocationStatusFromAPI | 19 | 1.4 |
| .../service/handlers.go | updateDriverVehicleTags | 18 | 1.3 |
| ...vice/service/cron.go | startCrons | 14 | 1.0 |
| ...rvice/service/api.go | startServer | 11 | 0.8 |
+-------------------------+-------------------------------+-----------------+--------+
- Support generation of HTML
- Integrate with gitlab