I used the following command to run test for specific package
go test fts -run run_test.go
can't load package: package fts: cannot find package "fts" in any of:/usr/local/Cellar/go/1.11.1/libexec/src/integration (from $GOROOT)/Users/i055555/go/src/fts (from $GOPATH)
And the package looks like
gitproj/
|---- fts
|---- -command
|---- -run.go
|---- -run_test.go
|---- internal
|---- -fs.go
|---- -tb.go
|---- -tb_test.go
main.go
So you can run go test
for a specific package by giving it the relative path:
go test ./fts/command
The --run
flag takes a regular expression that helps dictates which tests will be ran within the package.
For example if you had a test named TestFoo(...)
and another TestBar(...)
. go test --run=TestFoo
will only run TestFoo(...)
.