Skip to content

eventually without customization never runs test method #3988

@bddckr

Description

@bddckr

Using Kotest 5.8.1, the following test

class MyTestClass {
    @Test
    fun myTestMethod() = runTest {
        eventually {
            error("Whoops!")
        }
    }
}

(running in JUnit 4 - Android project)

immediately fails with

java.lang.AssertionError: Block failed after 0ms; attempted 0 time(s)

The test block is never run, and the output is really just the above, giving no further details about what went wrong.


I've dug into this and believe the issue is that the duration of the default EventuallyConfig is set to INFINITE:


which is then added to the start time:

which results in an overflow, I believe. The result is that the check against the end time is immediately failing
fun hasAttemptsRemaining() = timeInMillis() < end && iterations < config.retries


While I initially wanted to raise this as a documentation issue only, I do wonder whether a duration of INFINITE should be handled specifically to mean "retry forever". Currently it basically results in "attempt not even once". To clarify: While the default value could simply be changed, I'm instead suggesting that EventuallyControl should be changed to allow retrying forever.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions