Tests have two types of timeout that can be applied. The first is the overall time for all invocations of a test. This is just called timeout. The second is per individual run of a test, and this is called invocation timeout.
Kotest can be configured to invoke a test multiple times. For example,
In this case, a timeout of 2000 millis would cause the test to fail, because the total run time would be 4500 millis. Whereas an invocation timeout of 2000 millis would not cause the test to fail, because each individual run is 1500 millis.
The time taken for a test includes the execution time taken for nested tests, so factor this into your timeouts.
We can specify the timeout at three levels.
The most finely grained location for timeouts it on leaf tests directly.
Timeouts can be specified at the spec level for every test in that spec, unless overriden by the test case itself.
We can set global config in two ways - via system properties or by project config.
To set the global timeout or invocation timeout at the command line, use the system property
kotest.framework.invocation.timeout with a value in milliseconds.
We can set a global default for both timeout and invocationTimeout inside project config.
Global config is overridden by spec level and test case level values.