Go: Running Tests Excluding Vendor Packages
Many projects utilize the vendor folder to store external dependencies, which can sometimes lead to unwanted inclusion in tests. This article explores how to run Go tests on all test files except for those within the vendor package.
Various approaches have been attempted, such as using the -run option with a regex pattern. However, this method may encounter issues due to pattern matching limitations.
Fortunately, a simpler solution is available in Go 1.9 and later. The ... wildcard now excludes the ./vendor directory, making it easy to run tests on all other files:
go test ./...
This command will effectively run tests on all test files (e.g., foobar_test.go) excluding those located within the ./vendor directory.
The above is the detailed content of How to Exclude Vendor Packages When Running Go Tests?. For more information, please follow other related articles on the PHP Chinese website!