You could run go tool cover yourself, but getting the details right can be
difficult. Instead, I suggest moving the test code into the main package,
but protected by a build tag and called from the real test.
foo_test.go:
func TestFoo(t *testing.T) { mainTestFoo(t) }
foo.go:
func mainTestFoo(t *testing.T) { t.Helper(); ... }
The disadvantage is that you'd need to pass the build tag when you run the
test, but that is easy to do in a script.
-rob
On Wed, May 19, 2021 at 8:23 PM Piers Powlesland <[email protected]>
wrote:
> I'm working on a project with some quite complex test code and I'd like to
> be able to understand what parts of it are executing for certain tests. I
> generated coverage using the go test -coverprofile=coverage.out xxxx
> command but the coverage file only seems to contain information for non
> test files. Is it possible to extend the coverage to cover *_test.go files
> as well?
>
> Thanks,
>
> Piers
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/8b8ebbac-10fe-4fde-9f54-30cf53e2321dn%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/8b8ebbac-10fe-4fde-9f54-30cf53e2321dn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/CAOXNBZQpccCoC6ubO9auHC66SfEVfPe%2BHfGo4e6f50Z6wDXbog%40mail.gmail.com.