DEV Community 👩‍💻👨‍💻

Discussion on: Excluding files from code coverage in GO

Collapse
 
talalyousif profile image
Talal Yousif Author

One last thing to note, that I find interesting, is that one way to exclude a file from coverage natively would be to not have tests on the whole package. What I mean by this is: if you have a package called api and you have 3 files under this package, api_one.go, api_two.go and api_three.go. If you have no test files, then package api will not be counted towards the overall code coverage nor will it be considered to have 0% coverage. However, if you add a test file api_one_test.go, then your package will be included in the overall coverage percentage and it will have a coverage percentage value.