You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the Timeout rule, it would sometimes be convenient to be able to get how much time is remaining in the test. That would allow code that calls Future.get(long, Timeout), CountDownLatch.await(long, Timeunit), Thread.sleep(long), Object.wait(long), and any other code that waits to cooperate with the testing framework.
The use case for this is when bumping the timeout for a test, it becomes necessary to update all of the other uses of time. For example:
Suppose this test is slow or possibly flaky. Just incrementing the timeout to be higher won't work because the get is still going to fail early. Modifying the call to be future.get(Integer.MAX_VALUE, TimeUnit.SECONDS) is cumbersome and doesn't convey the intent of the test. As a strawman API, I would suggest something like the following:
It would be okay for this to not be exactly accurate (as compared with "deadlines"). It's more about letting the reader know that the waiting will happen to the end of the test, rather than some seemingly arbitrary duration.
The text was updated successfully, but these errors were encountered:
When using the
Timeout
rule, it would sometimes be convenient to be able to get how much time is remaining in the test. That would allow code that callsFuture.get(long, Timeout)
,CountDownLatch.await(long, Timeunit)
,Thread.sleep(long)
,Object.wait(long)
, and any other code that waits to cooperate with the testing framework.The use case for this is when bumping the timeout for a test, it becomes necessary to update all of the other uses of time. For example:
Suppose this test is slow or possibly flaky. Just incrementing the
timeout
to be higher won't work because the get is still going to fail early. Modifying the call to befuture.get(Integer.MAX_VALUE, TimeUnit.SECONDS)
is cumbersome and doesn't convey the intent of the test. As a strawman API, I would suggest something like the following:It would be okay for this to not be exactly accurate (as compared with "deadlines"). It's more about letting the reader know that the waiting will happen to the end of the test, rather than some seemingly arbitrary duration.
The text was updated successfully, but these errors were encountered: