testing - Is it possible to compile a Go program with specific flags for coverage analysis? -
is possible compile go program specific flags coverage analysis?
the use case:
- compile app;
- run functional automated tests;
- analyse coverage;
should similar gcov or python coverage.
many thanks!
yes, go has cover tool (as of version 1.2) incorporated test process. go test alone compile program , run automated tests may have. adding -cover flag provide statistics on test coverage.
to run it:
go test -cover you can output coverage profile:
go test -coverprofile=coverage.out and view with:
go tool cover -func=coverage.out or
go tool cover -html=coverage.out for html formatted output (with colour coding).
see http://blog.golang.org/cover , go tool cover -h , go testflag more info.
Comments
Post a Comment