timeout doesn't actually stop the test
See original GitHub issueThe current implementation of test timeouts makes the test’s result be failure but doesn’t actually proactively stop the test, so you can’t use it to make your tests end in a reasonable amount of time in failure.
For example, this diff applied to release/3.4
yields a failing test. (The embedded test here spins for a second.)
diff --git a/kotlintest-tests/kotlintest-tests-core/src/test/kotlin/com/sksamuel/kotlintest/TestCaseExecutorTest.kt b/kotlintest-tests/kotlintest-tests-core/src/test/kotlin/com/sksamuel/kotlintest/TestCaseExecutorTest.kt
index 51c67410..98f95459 100644
--- a/kotlintest-tests/kotlintest-tests-core/src/test/kotlin/com/sksamuel/kotlintest/TestCaseExecutorTest.kt
+++ b/kotlintest-tests/kotlintest-tests-core/src/test/kotlin/com/sksamuel/kotlintest/TestCaseExecutorTest.kt
@@ -8,6 +8,7 @@ import io.kotlintest.TestCase
import io.kotlintest.TestCaseConfig
import io.kotlintest.TestContext
import io.kotlintest.TestStatus
+import io.kotlintest.matchers.numerics.shouldBeLessThan
import io.kotlintest.milliseconds
import io.kotlintest.runner.jvm.TestCaseExecutor
import io.kotlintest.runner.jvm.TestEngineListener
@@ -258,12 +259,15 @@ class TestCaseExecutorTest : FunSpec() {
override fun description(): Description = Description.spec("wibble")
}
+ val executorStartTime = currentTimeMillis()
executor.execute(testCase, context)
+ val executorTotalTimeMillis = currentTimeMillis() - executorStartTime
then(listener).should().exitTestCase(
argThat { description == Description.spec("wibble") },
argThat { status == TestStatus.Error && this.error?.message == "Execution of test took longer than 125ms" }
)
+ executorTotalTimeMillis.shouldBeLessThan(500)
}
test("test with infinite loop but invocations = 1 should complete with TestStatus.Failure") {
The test is commented out on master and the code seems to be pretty rewritten, so maybe this is fixed in 4.0?
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
Selenium test timeout doesn't stop the test PHPUnit 3.6.10 ...
When a test tries to open a page that doesn't load, and the timeout value is reached, the test doesn't stop or throw...
Read more >Test time limits and timeouts - Visual Studio App Center
Timed-out test suites could be caused by an issue with test code or because the test suite is too large to complete within...
Read more >go test -timeout 30m can this be set inside Go code? disable ...
I have a long running test where I would like to set the testing package timeout to 30 minutes from with the my_test.go...
Read more >Asserting timeouts in JUnit 5 - Level Up Coding
This is better than stopping the test when you get tired of waiting, because if you have @After or @AfterClass procedures, those will...
Read more >Retry-ability - Cypress Documentation
Overriding the timeout to 0 will essentially disable retrying the query or waiting on an other, since it will spend 0 milliseconds retrying....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I agree that the timeout should apply per invocation. We can add another config value to support that.
https://github.com/kotest/kotest/issues/1442