Golang test coverage when test files outside package

Issue

I am trying to get the proper coverage amount of my code in the processor package using my test files that are in the test directory. I’ve tried numerous combinations of -cover and -coverpkg and cannot get it to work correctly. Can this be done while having the test files in separate package/folder?

.
├── internal
│   └── processor
└── test

Solution

I tracked down an answer and this is how I was able to accomplish my goal

go test -cover -coverpkg "./internal/processor" "./test"

Answered By – CoderSchmoder

Answer Checked By – Mildred Charles (GoLangFix Admin)

Leave a Reply

Your email address will not be published.