Skip to main content
The MobileBoost SDK for Espresso supports both Jetpack Compose and View/XML based Android apps.

Installation

Add the MobileBoost Android library to your dependencies (Maven Central):
build.gradle.kts (:app)
dependencies {
    // ...
    androidTestImplementation("io.mobileboost.gptdriver:gptdriver-compose:2.1.2")
    // ...
}
If needed, add packaging exclude rules in the android section of your build.gradle.kts (:app) file to resolve build failures caused by duplicate metadata files from dependencies:
build.gradle.kts (:app)
android {
    // ...
    packaging {
        resources {
            excludes.addAll(listOf("META-INF/INDEX.LIST", "META-INF/io.netty.versions.properties"))
        }
    }
    // ...
}
If not already present, add internet permissions to your AndroidManifest.xml:
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- ... -->
    
    <uses-permission android:name="android.permission.INTERNET" />
    
    <application>
        <!-- ... -->
    </application>
    <!-- ... -->
</manifest>

Jetpack Compose

Import the SDK and create a GptDriver instance in your test, passing the ComposeTestRule:
import io.mobileboost.gptdriver_ktl.GptDriver

@get:Rule
val composeTestRule = createComposeRule()

val sdkInstance = GptDriver(
    apiKey = "<YOUR_API_KEY>",
    deviceName = "Emulator",
    platformVersion = "N/A",
    additionalUserContext = "",
    cachingMode = "INTERACTION_REGION",
    testId = "",
    composeTestRule = composeTestRule
)

Caching modes

ModeDescription
NONENo caching
FULL_SCREENCache hit only if the full screen matches
INTERACTION_REGIONCache hit if the interaction region matches (recommended)

View/XML based apps

For traditional View-based apps, the setup is similar but uses an ActivityScenarioRule instead of ComposeTestRule.