1 回答

TA貢獻1797條經驗 獲得超6個贊
傳遞符合測試名稱的正則表達式應運行匹配的測試...
例如:
go test -v -cover --short -race ./... -run ^TestError*
運行不同的測試,這些測試從項目中的測試錯誤開始...
? github.com/user/project/internal/rabbitmq [no test files]
=== RUN TestErrorMiddleware
printer.go:54: GET http://localhost:45678/surprise
? http server started on [::]:45678
{"error":{"code":"EXPECTED","status":418},"level":"warning","msg":"expected: here's tea","time":"2021-08-06T17:25:58+03:00"}
--- PASS: TestErrorMiddleware (0.01s)
PASS
coverage: 54.8% of statements
ok ithub.com/user/project/internal/datadog 3.725s coverage: 70.6% of statements
? github.com/user/project/internal/ftp [no test files]
? github.com/user/project/internal/mongo [no test files]
testing: warning: no tests to run
PASS
coverage: 0.0% of statements
ok github.com/user/project/postgres 3.704s coverage: 0.0% of statements [no tests to run]
ok github.com/user/project/escrow 7.784s coverage: 0.0% of statements [no tests to run]
=== RUN TestError
--- PASS: TestError (0.00s)
=== RUN TestErrorHandling
--- PASS: TestErrorHandling (0.00s)
PASS
coverage: 70.6% of statements
...
目標對象是測試的名稱(函數名稱以Test)
- 1 回答
- 0 關注
- 103 瀏覽
添加回答
舉報