Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid timeout in go test after 10m

Tags:

go

go-testing

I'm currently running a suite of tests in Go using the go test ./... command. This suite contains multiple test functions, and the execution time exceeds 10 minutes. Unfortunately, the go test command is triggering a timeout error after the 10-minute mark.

I want to avoid using the --timeout flag to set a custom timeout value because I'm actively adding more test cases, and the required timeout value may change over time.

Is there a way to entirely disable the timeout feature in the go test command, or can it be set to an unlimited value?

Thank you.

like image 734
Sruthi CP Avatar asked Nov 07 '25 23:11

Sruthi CP


1 Answers

Using 0 for the timeout allows the tests to run forever:

go test -timeout 0

This is documented at go command: Testing flags:

  -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).
like image 154
icza Avatar answered Nov 09 '25 16:11

icza



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!