23
go test $(go list ./... | grep -v /vendor/) -coverprofile .testCoverage.txt

I am using the above command to test the files but there is 1 folder with the name "Store" that I want to exclude from tests. How it can be done?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
kishorK
  • 453
  • 2
  • 7
  • 16

1 Answers1

33

You're already doing it:

$(go list ./... | grep -v /vendor/)

The grep -v /vendor/ part is to exclude the /vendor/ directory. So just do the same for your Store directory:

go test $(go list ./... | grep -v /Store/) -coverprofile .testCoverage.txt

Note that excluding /vendor/ this way is not necessary (unless you're using a really old version of Go). If you are using an old version of Go, you can combine them:

go test $(go list ./... | grep -v /vendor/ | grep -v /Store/) -coverprofile .testCoverage.txt
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189