1 回答

TA貢獻(xiàn)2003條經(jīng)驗(yàn) 獲得超2個(gè)贊
您可以使用go test -run標(biāo)志并將其傳遞給您知道永遠(yuǎn)不會(huì)匹配的模式:
go test -run=XXX_SHOULD_NEVER_MATCH_XXX ./...
ok mypkg 0.731s [no tests to run]
這將捕獲任何測(cè)試編譯錯(cuò)誤——如果沒有——?jiǎng)t不會(huì)運(yùn)行任何測(cè)試。
如果您需要傳遞通常在您的go build過程中傳遞的任何構(gòu)建標(biāo)記(例如go build -tags mytag),您可以在以下過程中執(zhí)行相同的操作go test:
go test -tags mytag -run=XXX_SHOULD_NEVER_MATCH_XXX ./...
-run內(nèi)聯(lián) ( go help testflag) 文檔中有關(guān)標(biāo)志的完整詳細(xì)信息:
-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 關(guān)注
- 91 瀏覽
添加回答
舉報(bào)