Search code examples
androidandroid-espressoandroid-testingappium-androidandroid-uiautomator

androidTest vs Appium -- are both needed in a given project?


The formal Android Developers documentation provides an enlightening introduction to the Fundamentals of testing Android apps.

I managed to successfully create 3 different types of test setups in Android Studio for my app's project:

  1. test (Unit Tests) - These are local tests that run on the IDE's JVM and don't require an Android device or emulator. They're fast and used for testing individual components in isolation.
  2. androidTest (Instrumented Tests) - These tests run on an Android device or emulator and have access to instrumentation information, such as access to Context. They're part of the official Android testing framework.
  3. AppiumTest - (UI Automation Tests): Appium is a separate, cross-platform UI testing framework that can automate native, hybrid, and mobile web apps on Android, iOS, and Windows platforms.

So far, it looks like anything that androidTest can do, AppiumTest can do, too.

So the obvious question is why have both?

Are there compelling reasons to maintain both androidTest and AppiumTest?


Solution

  • You correctly spotted that there is a significant overlap between androidTest and AppiumTest.

    If your app is Android-only, androidTest might be sufficient, as it has the following advantages:

    1. Native Integration: androidTest is natively integrated with Android Studio and the Android build system. This means easier setup, maintenance, and execution within your development environment.
    2. Performance: Instrumented tests (androidTest) generally run faster than Appium tests because they have direct access to the app's internals and don't rely on an additional layer of abstraction.
    3. Android-specific Features: androidTest provides access to Android-specific testing tools and APIs that might not be available or as easily accessible through Appium..

    Still, I can think of some reasons why you might want to maintain both:

    1. Cross-platform: If you're developing for multiple platforms, Appium allows you to write tests that can run on both Android and iOS with minimal changes.
    2. Testing Scope: androidTest is often used for lower-level integration tests and UI tests specific to Android, while Appium is typically used for higher-level, end-to-end tests that might simulate real user scenarios across the entire app.