From 6946b977ec59578ce44ed63ea627e25ba688caf1 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 6 Dec 2024 18:40:14 +0100 Subject: [PATCH] test(SimPinFeederTest): attempt to address test flakiness due to timeout (#41) This occurs only on 'release' builds... presumably because of bytecode optimizations, which reduces overall execution time. To address this, we'll allow a max. discrepancy of 250ms. org.awaitility.core.ConditionTimeoutException: Condition was evaluated in 2 seconds 958 milliseconds which is earlier than expected minimum timeout 3 seconds at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:172) at org.awaitility.core.CallableCondition.await(CallableCondition.java:78) at org.awaitility.core.CallableCondition.await(CallableCondition.java:26) at org.awaitility.core.ConditionFactory.until(ConditionFactory.java:1006) at org.awaitility.core.ConditionFactory.until(ConditionFactory.java:975) at com.github.iusmac.sevensim.telephony.SimPinFeederTest.assertTaskTimedOut(SimPinFeederTest.java:906) at com.github.iusmac.sevensim.telephony.SimPinFeederTest.test_ShouldFinishAfterExceedingFixedWaitTimeoutForSimStatusChangeEventWhenAvailableSimCardsDoNotRequirePin(SimPinFeederTest.java:219) Signed-off-by: iusmac --- .../github/iusmac/sevensim/telephony/SimPinFeederTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test/java/com/github/iusmac/sevensim/telephony/SimPinFeederTest.java b/tests/test/java/com/github/iusmac/sevensim/telephony/SimPinFeederTest.java index e3737e5..12de4fb 100644 --- a/tests/test/java/com/github/iusmac/sevensim/telephony/SimPinFeederTest.java +++ b/tests/test/java/com/github/iusmac/sevensim/telephony/SimPinFeederTest.java @@ -900,8 +900,9 @@ private void assertTaskTimedOut() { await() .dontCatchUncaughtExceptions() .pollInSameThread() - .atMost(TASK_WAIT_TIMEOUT_DURATION.plusMillis(250L)) - .atLeast(Duration.ofSeconds(3)) + .atMost(TASK_WAIT_TIMEOUT_DURATION) + .atLeast(TASK_WAIT_TIMEOUT_DURATION.minusMillis(250L)) + .pollInterval(Duration.ofMillis(50)) .until(() -> mTask.getState() == TERMINATED); }