ExpectIt icon indicating copy to clipboard operation
ExpectIt copied to clipboard

Interact does not work when using infinite timeout

Open jacobthughes opened this issue 5 years ago • 0 comments

Using .withInfiniteTimout() sets the timeout value to -1. In the until method of InteractBuilderImpl we then have the following:

final long time = System.currentTimeMillis();
...
if (System.currentTimeMillis() - time > expect.getTimeout()) {
        LOG.fine("Until matching operation timeout");
        return (R) SimpleResult.failure(inputBuffer, true);
}

Since getTimeout() will evaluate to -1, this will enter the if statement and return as a failure.
So any interact statement I built using an expect with infinite timeout will not function, and will simply exit without even evaluating the matchers.

Setting the timeout to something huge (e.g. 10 days) is a work-around.

jacobthughes avatar Jan 10 '20 17:01 jacobthughes