https://kotlinlang.org logo
#compose
Title
# compose
e

eygraber

06/10/2022, 12:07 AM
Are there any tricks to testing
LaunchedEffect
as far as
TestDispatcher
is concerned? I'm trying to
advanceTimeBy
past a
delay
in a
LaunchedEffect
but that isn't working because the dispatcher is a
AndroidUiDispatcher
(or
FlushCoroutineDispatcher
in desktop). As far as I can tell, the only way around this is to create a new context (
launch
,
withContext
, etc...) that uses the
TestDispatcher
. Is that correct, or am I missing something?
z

Zach Klippenstein (he/him) [MOD]

06/10/2022, 12:28 AM
Are you using the
TestDispatcher
from the coroutines testing library?
e

eygraber

06/10/2022, 12:32 AM
Yes, I'm passing
UnconfinedTestDispatcher
to `runTest`:
e

ephemient

06/10/2022, 1:29 AM
e

eygraber

06/10/2022, 1:48 AM
I can try that, but
runComposeUiTest
isn't resolving for me on CfD 1.2.0 latest dev build.
MainTestClock
is resolving.
Although what I'm testing now relies on
ImageComposeScene
and those don't seem compatible.
z

Zach Klippenstein (he/him) [MOD]

06/10/2022, 4:21 PM
I'm not sure what the right approach is, @Jelle Fresen [G] ?
e

eygraber

06/10/2022, 11:12 PM
@Igor Demin it looks like this wasn't pulled into CfD dev builds yet. Is that accurate?
I re-wrote all the tests I had for CfD for Android and they all work, so I'm assuming that CfD's test code doesn't have the latest from upstream? Or there are inconsistencies between the environments that needs addressing in CfD?
i

Igor Demin

06/14/2022, 3:18 PM
Yes, CfD still don’t have
runComposeUiTest
, because the latest rebase on Jetpack Compose was on 12 of April, but the feature was merged on 28 of April. The next rebase will be in about a month.
🙏 1
156 Views