onsi / ginkgo

A Modern Testing Framework for Go
http://onsi.github.io/ginkgo/
MIT License
8.22k stars 650 forks source link

Is there a way to exclude mocks in generating code coverage? #1247

Open weikequ opened 1 year ago

weikequ commented 1 year ago

If I do something like ginkgo --cover --converprofile='test.out' ./..., is there any way to ignore the mocks directory in generating coverages/composite coverage values? I've searched around the internet and forums and didn't see a way to do this.

onsi commented 1 year ago

FWIW since ginkgo is just using go test under the hood you could google how to do this with standard go test. That might give you more results. I don't typically use mocks so haven't run into this issue... and I know that -coverpkg allows you to include additonal packages, but I don't think it lets you exclude packages. This stackoverflow post seems related to what you're asking about:

https://stackoverflow.com/questions/50065448/how-to-ignore-generated-files-from-go-test-coverage