测试被退出杀死:运行时间太长

Test killed with quit: ran too long

我运行 go test 并遇到超时错误:

*** Test killed with quit: ran too long (10m0s).
FAIL    call/httptest   600.050s

如何延长超时并使其大于 10 分钟?

使用go test -timeout <duration>,例如:

$ go test -timeout 20m

默认为10m。

来自the docs

Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".

默认10分钟后超时退出

go test --help

-timeout d If a test binary runs longer than duration d, panic. If d is 0, the timeout is disabled. The default is 10 minutes (10m).