Writing tests
Use androidTest, iosTest, or appiumTest as the entry point. Each creates a driver session, runs the test body, and guarantees cleanup.
The single navigation verb is on - use it for every screen interaction, whether it's the first screen after launch, a screen reached via navigation, or a screen landed on via deep link.
Android
@Test
fun checkout() = androidTest(app = MyAndroidApp) {
on(::ProductsScreen) {
titleText() shouldBe "Products"
selectProduct("Backpack")
}.on(::ProductDetailsScreen) {
addToCart()
}
}
iOS
@Test
fun checkout() = iosTest(app = MyIosApp) {
on(::ProductsScreen) {
titleText() shouldBe "Products"
}
}
Cross‑platform
Pass the platform‑specific factory explicitly:
@Test
fun checkout_android() = appiumTest(
app = MyApp,
driverFactory = MyApp.androidDriverFactory,
) {
on(::ProductsScreen) {
// test body
}
}
@Test
fun checkout_ios() = appiumTest(
app = MyApp,
driverFactory = MyApp.iosDriverFactory,
) {
on(::ProductsScreen) {
// test body
}
}
setUp / tearDown
appiumTest supports computing a fixture before the session and tearing it down afterward, even on failure:
data class Fixture(val user: User)
@Test
fun purchase_flow() = appiumTest(
app = MyAndroidApp,
driverFactory = MyAndroidApp.driverFactory,
setUp = { Fixture(seedUser()) },
tearDown = { fixture -> deleteUser(fixture.user) },
) { fixture ->
// use fixture.user in the test body
}