diff --git a/app/src/androidTest/java/com/growingio/demo/AbstractGrowingTestUnit.kt b/app/src/androidTest/java/com/growingio/demo/AbstractGrowingTestUnit.kt index 4ccaad9..6d7df4c 100644 --- a/app/src/androidTest/java/com/growingio/demo/AbstractGrowingTestUnit.kt +++ b/app/src/androidTest/java/com/growingio/demo/AbstractGrowingTestUnit.kt @@ -106,6 +106,7 @@ abstract class AbstractGrowingTestUnit { timeout: Long = 5, unit: TimeUnit = TimeUnit.SECONDS, validateAtLast: Boolean = false, + throwException: Boolean = true, testBody: suspend () -> Unit, ) { runTest(timeout = 20.seconds) { @@ -119,7 +120,11 @@ abstract class AbstractGrowingTestUnit { withContext(Dispatchers.IO) { while (countDownLatch.count > 0) { if (System.nanoTime() > end) { - throw TimeoutException("Already waited for the $eventType Event to pass ${timeout}s, timed out") + if (throwException) { + throw TimeoutException("Already waited for the $eventType Event to pass ${timeout}s, timed out") + } else { + println("Already waited for the $eventType Event to pass ${timeout}s, timed out") + } } Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS) } diff --git a/app/src/androidTest/java/com/growingio/demo/ui/material/SliderFragmentTest.kt b/app/src/androidTest/java/com/growingio/demo/ui/material/SliderFragmentTest.kt index f1e5218..09df365 100644 --- a/app/src/androidTest/java/com/growingio/demo/ui/material/SliderFragmentTest.kt +++ b/app/src/androidTest/java/com/growingio/demo/ui/material/SliderFragmentTest.kt @@ -74,7 +74,7 @@ class SliderFragmentTest : AbstractGrowingTestUnit() { @Test fun onSeekBarTest() { - runEventTest(AutotrackEventType.VIEW_CHANGE, onEvent = { baseEvent -> + runEventTest(AutotrackEventType.VIEW_CHANGE, throwException = false, onEvent = { baseEvent -> if (baseEvent is ViewElementEvent) { Truth.assertThat(baseEvent.eventType).isEqualTo(AutotrackEventType.VIEW_CHANGE) Truth.assertThat(baseEvent.path).isEqualTo("/SliderFragment")