While running the go test under a package, how to skip a go file in test as well as in the coverage report

I want to skip a particular go file under a package ,while running the go test and coverage.
Please find the below command , I have used to run under my service package :-
cd src/service && go test --coverprofile coverageService.out --coverpkg ./.

You can use build tags for this. At the top of your file, add

// +build !skip

and then run go test with -t skip.

1 Like

I have tried this. The test case is getting skipped, but the source code for that test case is not excluded in cover tool. How can i ignore that source file under the package, while running the coverage tool.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.