From f731c47c5bafe6d443aca897219c2a1d5921a92a Mon Sep 17 00:00:00 2001 From: Mike Hardy Date: Thu, 12 May 2022 08:41:17 -0500 Subject: [PATCH] fix(test): shorten time and use greaterThanOrEqualTo for sleep test --- AnkiDroid/src/test/java/com/ichi2/utils/ThreadUtilTest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AnkiDroid/src/test/java/com/ichi2/utils/ThreadUtilTest.kt b/AnkiDroid/src/test/java/com/ichi2/utils/ThreadUtilTest.kt index d49a303391..281f085f97 100644 --- a/AnkiDroid/src/test/java/com/ichi2/utils/ThreadUtilTest.kt +++ b/AnkiDroid/src/test/java/com/ichi2/utils/ThreadUtilTest.kt @@ -18,7 +18,7 @@ package com.ichi2.utils import android.annotation.SuppressLint import org.hamcrest.MatcherAssert.assertThat -import org.hamcrest.Matchers.greaterThan +import org.hamcrest.Matchers.greaterThanOrEqualTo import org.junit.Test class ThreadUtilTest { @@ -28,10 +28,10 @@ class ThreadUtilTest { fun sleepTest() { val start: Long = System.currentTimeMillis() - ThreadUtil.sleep(1000) // makes the thread sleep for 1 second + ThreadUtil.sleep(100) // makes the thread sleep for a short while val end: Long = System.currentTimeMillis() - assertThat(end - start, greaterThan(1000)) // checking if the time difference between "end" and "start" is greater than the time thread has been put to sleep + assertThat(end - start, greaterThanOrEqualTo(100)) // checking if the time difference between "end" and "start" indicates we actually slept } }