https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
i

Igor Milakovic

03/14/2022, 6:25 PM
How do you guys run your tests in the shared module? I was following this article but it doesn't quite work as expected: https://touchlab.co/understanding-and-configuring-your-kmm-test-suite/ The suggested
./gradlew :shared:allTests
does not run Android tests. That's not that big of a deal, since
./gradlew :shared:check
does run both. But the problem is that running any of those repeatedly doesn't fail any longer when iOS tests fail. Luckily, can be fixed by adding
:shared:clean
before
:shared:check
but then it doesn't proceed with Android tests after iOS fails... And so on, haha. So yeah, how do you people run your tests, what is the magic command/configuration? 🙂 Thanks!
m

Matti MK

03/14/2022, 6:35 PM
You can run
./gradlew tasks --all
to show all tasks. I run:
:shared:iosTest
-> “Executes Kotlin/Native unit tests for target ios.” and
:shared:testDebugUnitTest
-> “Run unit tests for the debug build” (this one runs only for Android)
If you run
./gradlew :shared:allTests --dry-run
you can see the list of tasks that are executed for that given task. For me there’s no indications about running any Android related tests
j

Javier

03/14/2022, 6:44 PM
Looks like a bug with Gradle cache that should be reported to the Kotlin team
m

mkrussel

03/14/2022, 7:12 PM
allTests
are all tests except for Android with Android being a special and having multiple test tasks of its own created by the AGP. Since each platform's tests are different task, gradle does stop after the first task failure unless you use
--continue
, But that will also make it try to continue on compile failures, so I'm not a fan of using it. I'm not sure if not running the
iosTest
with no changes is a bug with cache. You can run
cleanAllTests
to clean the non Android tests and force them to be run again.
j

Javier

03/14/2022, 8:22 PM
if running check fails and rerunning it passes, it is a bug
m

mkrussel

03/14/2022, 8:23 PM
I would agree with that, if the task failed it should not get cached or it needs to cache the failure status.
i

Igor Milakovic

03/14/2022, 9:15 PM
Thanks guys, this was very helpful! Much appreciated 🙂
16 Views