New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eventually
without customization never runs test method
#3988
Comments
@mirageoasis I think we could solve it by changing Line 208 in 4ad8070
to val end = maxOf(Long.MAX_VALUE, start + config.duration.inWholeMilliseconds) // prevent overflow I think we could also reconsider using |
well that case only end up fixing end to Long.MAX_VALUE so I don't think it will be helpful instead I suggest using code something like this fun addSafely(a: Long, b: Long): Long {
val sum = a + b
if (a > 0 && b > 0 && sum < 0) {
return Long.MAX_VALUE
} else if (a < 0 && b < 0 && sum > 0) {
return Long.MIN_VALUE
} else {
return sum
}
}
kind of prototype code |
Will |
if val end = maxOf(Long.MAX_VALUE, start + 5) and end value will be |
instead I suggest other solution Line 245 in 4ad8070
instead fixing like if end value is already minus it makes while infinite loop what about my idea? |
Feel free to publish a draft for further discussion :) |
Using Kotest
5.8.1
, the following test(running in JUnit 4 - Android project)
immediately fails with
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 defaultEventuallyConfig
is set toINFINITE
:kotest/kotest-assertions/kotest-assertions-core/src/commonMain/kotlin/io/kotest/assertions/nondeterministic/eventually.kt
Line 118 in 4ad8070
which is then added to the start time:
kotest/kotest-assertions/kotest-assertions-core/src/commonMain/kotlin/io/kotest/assertions/nondeterministic/eventually.kt
Line 208 in 4ad8070
which results in an overflow, I believe. The result is that the check against the end time is immediately failing
kotest/kotest-assertions/kotest-assertions-core/src/commonMain/kotlin/io/kotest/assertions/nondeterministic/eventually.kt
Line 245 in 4ad8070
While I initially wanted to raise this as a documentation issue only, I do wonder whether a
duration
ofINFINITE
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 thatEventuallyControl
should be changed to allow retrying forever.The text was updated successfully, but these errors were encountered: