Getting cross-package test coverage data?

115 views
Skip to first unread message

Tom Payne

unread,
May 14, 2020, 12:19:58 AM5/14/20
to golang-nuts
What's the current state of getting combined cross-package test coverage data? Specifically:
  • I have a lib directory containing my library code, which has some tests, but not many.
  • I have a cmd directory containing my main code and many tests that exercises the code in lib .
  • I want to know what code in lib is covered by my tests in cmd (and, more specifically, which code in lib is not covered by the tests so I can add more tests).
My current understanding is I need to use a third-party tool to merge coverage, like https://github.com/ory/go-acc.

Is this correct?

Many thanks,
Tom

pankaj pipada

unread,
May 14, 2020, 8:46:43 AM5/14/20
to Tom Payne, golang-nuts
Not sure if a tool is required. 
It can be done with a couple of commands. 
An elaborate example (of coverage across different types of tests, etc) is provided at: https://www.elastic.co/blog/code-coverage-for-your-golang-system-tests

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/3e24588a-005e-4072-80fe-ff7a912bd368%40googlegroups.com.


--
Pankaj Pipada

twp...@gmail.com

unread,
Sep 29, 2021, 11:57:50 PM9/29/21
to golang-nuts
Very, very, late response to this, but I was missing the `-coverpkg=./...` argument to `go test`. /facepalm
Reply all
Reply to author
Forward
0 new messages