gogo-testing

How to avoid timeout in go test after 10m


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.


Solution

  • 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).