我使用以下命令对特定包运行测试
去测试 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)
包裹看起来像
gitproj/
|---- fts
|---- -command
|---- -run.go
|---- -run_test.go
|---- internal
|---- -fs.go
|---- -tb.go
|---- -tb_test.go
main.go
最佳答案
因此,您可以通过为特定包指定相对路径来运行 go test
:
go test ./fts/command
--run
标志采用正则表达式来帮助指示将在包中运行哪些测试。
例如,如果您有一个名为 TestFoo(...)
的测试和另一个名为 TestBar(...)
的测试。 go test --run=TestFoo
只会运行 TestFoo(...)
。
关于go - 为特定包运行 go test,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53571646/