1 回答
TA贡献2003条经验 获得超2个赞
您可以使用go test -run标志并将其传递给您知道永远不会匹配的模式:
go test -run=XXX_SHOULD_NEVER_MATCH_XXX ./...
ok mypkg 0.731s [no tests to run]
这将捕获任何测试编译错误——如果没有——则不会运行任何测试。
如果您需要传递通常在您的go build过程中传递的任何构建标记(例如go build -tags mytag),您可以在以下过程中执行相同的操作go test:
go test -tags mytag -run=XXX_SHOULD_NEVER_MATCH_XXX ./...
-run内联 ( go help testflag) 文档中有关标志的完整详细信息:
-run regexp
Run only those tests, examples, and fuzz tests matching the regular
expression. For tests, the regular expression is split by unbracketed
slash (/) characters into a sequence of regular expressions, and each
part of a tests identifier must match the corresponding element in
the sequence, if any. Note that possible parents of matches are
run too, so that -run=X/Y matches and runs and reports the result
of all tests matching X, even those without sub-tests matching Y,
because it must run them to look for those sub-tests.
- 1 回答
- 0 关注
- 68 浏览
添加回答
举报