my tests were a mess for years. going multiplatform accidentally fixed them
i build a fitness tracker. android + ios.
my old android testing setup was a lie.
unit tests for the easy stuff. robolectric for framework things. a pile of flaky instrumentation tests i quietly stopped running. everything else? "i'll test it manually."
then i went KMM. and shared code physically can't touch android APIs.
that one constraint fixed more than any testing book i ever read.
what my tests look like now:
presenters are molecule composables returning StateFlow. no viewmodel. no android lifecycle. so presenter tests are plain JVM tests — push events in, assert on state. kotlin-test + runTest + turbine. they run in seconds.
they've never flaked. not once. there's nothing left to flake — no emulator, no framework, no clock weirdness.
use cases and repos: same deal. interfaces everywhere, fakes instead of mocks. camera/notifications/storage hide behind interfaces, shared code tests against fakes.
one test i'd force every koin user to write: boot every DI module, resolve the whole graph. koin fails at runtime, not compile time. this single test saved me from maybe five embarrassing releases.
what i lost: UI tests. compose multiplatform test tooling is young and i'm one person. so i made screens dumb — they render state, forward events, decide nothing. if the screen compiles and the presenter is right, remaining bugs are cosmetic.
might not survive a real team. works great solo.
the actual lesson (works even if you never touch KMP):
fast reliable tests don't come from testing tools. they come from architecture that keeps logic out of framework classes. KMP just forced me to do what i should've done years ago.
anyone actually running compose UI tests in CI and happy? genuinely asking.