go - 为特定包运行 go test

标签 go

我使用以下命令对特定包运行测试

去测试 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/

相关文章:

debugging - 戈格兰 : debugging has redundant parameter '--'

authentication - 用于 golang 应用程序的 Keycloak 适配器

去旅游练习#7 : Binary Trees equivalence

go - Go中的N叉树

go - goroutines到底是什么?

swift - http Post 说它可以工作,但它没有在本地主机上发布

json - 使用 json.RawMessage 将 json 解码为结构

ssl - 去接受来自远程主机的自签名证书

go - Go 中的堆排序实现

go - 如何在golan main函数中调用一个没有输入和输出的函数?