02/04/2020 - GO
This example outputs final test coverage report. It break downs coverage by functions in each file. Finally the report outputs overall test coverage.
This covers all files.
go test -v -coverpkg=./... -coverprofile=coverage.log ./...
go tool cover -func coverage.log
This excludes all files in /internal/pkg/test
folder.
go test -v -coverpkg=./... -coverprofile=coverage.tmp ./...
cat coverage.tmp | grep -v /internal/pkg/test > coverage.log
go tool cover -func coverage.log
For the first line, prefer this. See what exactly flags do.
go test -v -race -bench -benchmem -timeout=120s -count=1 -cover -coverpkg=./... -coverprofile=coverage.tmp ./...
github.com/Inanzzz/game/cmd/gouthenticator/main.go:15: main 0.0%
github.com/Inanzzz/game/internal/app/gouthenticator.go:14: New 0.0%
github.com/Inanzzz/game/internal/app/gouthenticator.go:21: Start 0.0%
github.com/Inanzzz/game/internal/home/controller.go:11: NewController 100.0%
github.com/Inanzzz/game/internal/home/controller.go:15: Handle 0.0%
github.com/Inanzzz/game/internal/home/router.go:9: Routes 0.0%
github.com/Inanzzz/game/internal/league/create/controller.go:16: NewController 0.0%
github.com/Inanzzz/game/internal/league/create/controller.go:25: Handle 0.0%
github.com/Inanzzz/game/internal/league/create/repository.go:16: NewRepository 0.0%
github.com/Inanzzz/game/internal/league/create/repository.go:25: create 0.0%
github.com/Inanzzz/game/internal/league/create/request.go:20: NewRequest 0.0%
github.com/Inanzzz/game/internal/league/create/response.go:9: NewResponse 0.0%
github.com/Inanzzz/game/internal/league/create/service.go:16: NewService 0.0%
github.com/Inanzzz/game/internal/league/create/service.go:24: create 0.0%
github.com/Inanzzz/game/internal/league/delete/controller.go:17: NewController 0.0%
github.com/Inanzzz/game/internal/league/delete/controller.go:26: Handle 0.0%
github.com/Inanzzz/game/internal/league/delete/repository.go:16: NewRepository 0.0%
github.com/Inanzzz/game/internal/league/delete/repository.go:25: deleteOneByUUID 0.0%
github.com/Inanzzz/game/internal/league/delete/request.go:14: NewRequest 0.0%
github.com/Inanzzz/game/internal/league/delete/service.go:16: NewService 0.0%
github.com/Inanzzz/game/internal/league/delete/service.go:24: delete 0.0%
github.com/Inanzzz/game/internal/league/list/controller.go:16: NewController 0.0%
github.com/Inanzzz/game/internal/league/list/controller.go:25: Handle 0.0%
github.com/Inanzzz/game/internal/league/list/repository.go:32: NewRepository 0.0%
github.com/Inanzzz/game/internal/league/list/repository.go:41: list 0.0%
github.com/Inanzzz/game/internal/league/list/request.go:15: NewRequest 0.0%
github.com/Inanzzz/game/internal/league/list/response.go:16: NewResponse 0.0%
github.com/Inanzzz/game/internal/league/list/service.go:15: NewService 0.0%
github.com/Inanzzz/game/internal/league/list/service.go:23: list 0.0%
github.com/Inanzzz/game/internal/league/retrieve/controller.go:17: NewController 100.0%
github.com/Inanzzz/game/internal/league/retrieve/controller.go:26: Handle 91.3%
github.com/Inanzzz/game/internal/league/retrieve/repository.go:30: NewRepository 100.0%
github.com/Inanzzz/game/internal/league/retrieve/repository.go:39: findOneLeagueByUUID 90.0%
github.com/Inanzzz/game/internal/league/retrieve/request.go:14: NewRequest 100.0%
github.com/Inanzzz/game/internal/league/retrieve/response.go:16: NewResponse 100.0%
github.com/Inanzzz/game/internal/league/retrieve/service.go:15: NewService 100.0%
github.com/Inanzzz/game/internal/league/retrieve/service.go:23: retrieve 71.4%
github.com/Inanzzz/game/internal/league/router.go:15: Routes 0.0%
github.com/Inanzzz/game/internal/pkg/bootstrap/config.go:33: NewConfig 0.0%
github.com/Inanzzz/game/internal/pkg/bootstrap/config.go:65: env 0.0%
github.com/Inanzzz/game/internal/pkg/bootstrap/server.go:11: NewHTTPServer 0.0%
github.com/Inanzzz/game/main.go:17: main 0.0%
github.com/Inanzzz/game/main.go:38: Read 0.0%
total: (statements) 19.3%