stuff/stuff.go -> package: stuff
test/stuff/stuff_test.go -> package: test
Although stuff_test executes code from stuff.go it shows
coverage: 0.0% of statements
go test -cover
If I move my *_test.go to the stuff-folder of the program it is working fine.
Or perhaps my approach of the project-structure is not well designed/go-conform?
Cross-package test coverage is not directly supported, but several people have built wrappers to merge individual coverage profiles.
See Issue #6909 for the long history on this. And see gotestcover for an example tool to do the merging. There’s also gocovmerge. I built my own version, so I haven’t tried any of these, but I’m sure they all work like mine, and mine works fine.
My sense is that this is just an issue that no one has written a really compelling changelist for, and hasn’t been that important to the core maintainers, so it hasn’t been addressed. It does raise little corner cases that might break existing tests, so the quick hacks that work for most of us haven’t been accepted as-is. But I haven’t seen any discussion suggesting the core maintainers actively object to this feature.
Answered By – Rob Napier
Answer Checked By – Mary Flores (GoLangFix Volunteer)