Top 5 Android Testing Frameworks with Code Examples

Top 5 Android Testing Frameworks

With the rollout of Android Oreo, Google’s mobile ecosystem continues to expand rapidly. It is evident that new mobile OEMs are emerging in every corner of the world, bringing in different screen sizes, ROM/firmware, chipsets, etc. The complexity of Android app testing has been growing all the time. 

To cope with increasing testing workload, it has become a common practice to rely on a cloud-based Android app testing solution to automate scripted tests on a large scale of real devices for extensive QA. Though there are multiple choices on Android testing frameworks, it’s critical to understand the basics and how each framework performs so the selected tool can help you meet your testing needs and ultimately achieve your business goals.

Today we are going to behold 5 most used Android testing frameworks and break down the basics and code examples of each. Should you be working on iOS apps at the same time, you can also check out top 5 iOS test automation frameworks with code examples here.


Appium is a mobile test automation framework (and tool) for native, hybrid and web apps for iOS and Android. It uses JSONWireProtocol internally to interact with iOS and Android apps using Selenium’s WebDriver. It supports Android via uiautomator (API level 16 or higher) and Seledroid (API level lower than 16), iOS via UI Automation, and mobile web as Selenium driver for Android and iOS. Looking for a complete Appium tutorial for mobile app testing?

One of the biggest advantages of Appium is that you can write your Appium scripts in almost any programming language (e.g. Java, Objective-C, JavaScript, PHP, Ruby, Python or C#, etc), freedom from having to select tools, compatibility across the most important platforms (Android and iOS), freedom from having to install and configure devices to test and more. Also if you are familiar with Selenium, then it’s easy for you to use Appium in mobile app testing. They use the same WebDriver and DesiredCapabilities is used in the same way. Configuring an application to run on Appium has a lot of similarities to Selenium.

Appium code example:

# wait for hello
 textFields = driver.find_elements_by_tag_name('textField')
 assertEqual(textFields[0].get_attribute("value"), "Hello")
 # click sign-in button
 driver.find_elements_by_name('Sign in')[0].click()
 # find the text fields again, and enter username and password
 textFields = driver.find_elements_by_tag_name('textField')
 # click the Login button (the first button in the view)
 # sleep
 # click the first button with name "Compose"
 # type in the tweet message
 driver.find_elements_by_tag_name('textField')[0].send_keys(”#Bitbar is awesome!")
 # press the Send button
 # exit


Calabash is a cross-platform test automation framework for Android and iOS native and hybrid applications. Calabash’s easy-to-understand syntax enables even non-technical people to create and execute automated acceptance tests for apps on both of these mobile platforms. Calabash’s tests are described in Cucumber and then converted to Robotium or Frank in run time. It supports about 80 different natural language commands (controllers), and new controllers can be implemented in Ruby or Java. To learn more, this Calabash 101 ebook will give you an extensive understanding.

Calabash code example:

Feature: Login feature
 Scenario: As a valid user I can log into my app
 I wait for text "Hello"
 Then I press view with id "Sign in"
 Then I enter text "username" into "login_username"
 Then I enter text "password" into "login_password"
 Then I wait for activity "HomeTabActivity"
 Then I press view with id "menu_compose_tweet"
 Then I enter text "Bitbar" into field with id "edit"
 Then I press view with id "composer_post"


Espresso is the latest Android test automation framework that got open-sourced by Google, making it available for developers and testers to hammer out their UIs. Espresso has an API that is small, predictable, easy to learn and built on top of the Android instrumentation framework. You can quickly write concise and reliable Android UI tests with it. It is supported on API level 8 (Froyo), 10 (Gingerbread), and 15 (Ice Cream Sandwich) and onwards.
It’s quite reliable, synchronizing with the UI thread and fast because there is no need for any sleeps (tests run on same millisecond when an app becomes idle). But it does not have support for webviews as well.

Espresso code example:

public void testEspresso() {
 // Check if view with the text 'Hello.' is shown
 // R class ID identifier for 'Sign in' - and click it
 .getIdentifier("", null, null))).perform(click());
 // R class ID identifier for entering username
 .getIdentifier("", null, null))).perform((typeText("username")));
 // R class ID identifier for entering password
 .getIdentifier("", null, null))).perform((typeText("password")));
 // R class ID identifier for clicking log in
 .getIdentifier("", null, null))).perform(click());
 // Activate the text field to compose a tweet
 .getIdentifier("", null, null))).perform(click());
 // Type the tweet
 .getIdentifier("", null, null))).perform((typeText(”#Bitbar")));
 // Tweeting!
 .getIdentifier("", null, null))).perform(click());

Check Android Espresso Tutorial for more information or alternatively see the demo of running Espresso tests on real devices at Bitbar Cloud.


While Robotium is a good yet basic framework, uiautomator allows you to do more in testing Android apps and games. Google’s test framework allows you to test user interface (UI) of your native Android apps on one or more devices. Another advantage of uiautomator is that it runs JUnit test cases with special privileges, which means test cases can span across different processes. It also provides five different classes for developers to use, including;;;;

Similar to its time of birth, it only works on Android devices with API level 16 or higher. Another downside of uiautomator is that it doesn’t support Webview, with no way to directly access Android objects.

uiautomator’s code example:

// Public void for the operation
 public void testSignInAndTweet() throws Exception {
 // Starting application:
 getUiDevice().wakeUp(); // Press Home button to ensure we're on homescreen
 getUiDevice().pressHome(); // Select 'Apps' and click button
 new UiObject(new UiSelector().description("Apps")).click(); // Select 'Twitter' and click
 new UiObject(new UiSelector().text("Twitter")).click(); // Locate and select 'Sign in'
 UiSelector signIn = new UiSelector().text("Sign In"); // If button is available, click
 UiObject signInButton = new UiObject(signIn);
 if (signInButton.exists()) {; // Set the username
 new UiObject(new
 new UiObject(new
 new UiObject(new UiSelector().className("android.widget.Button").
 text("Sign In").instance(0)).click(); // Wait Sign in progress window
 getUiDevice().waitForWindowUpdate(null, 2000); // Wait for main window
 getUiDevice().waitForWindowUpdate(null, 30000);
 new UiObject(new UiSelector().description("New tweet")).click(); // Typing text for a tweet
 new UiObject(new UiSelector().className("android.widget.LinearLayout").instance(8)).
 setText("Awesome #Bitbar!"); // Tweeting!
 new UiObject(new UiSelector().text("Tweet")).click();


Undoubted, Robotium was once the most widely used Android testing framework in the early days of the Android world. With a similarity with Selenium in Android, it makes testing API simpler.
Robotium is an open source library extending JUnit with plenty of useful methods for Android UI testing. It provides powerful and robust automatic black-box test cases for Android apps (native and hybrid) and web testing. With Robotium you can write function, system and acceptance test scenarios, and test applications where the source code is available.

Robotium code example:

// Public void for the operation
 public void testRecorded() throws Exception {
 // Wait for the text 'Hello!' to be shown for newbie
 if (solo.waitForText("Hello!")) {
 // R class ID identifier for 'Sign in' - and click it
 // R class ID identifier for entering username
 solo.enterText((EditText) solo.findViewById(""),"username");
 // R class ID identifier for entering password
 solo.enterText((EditText) solo.findViewById(""),"password");
 // R class ID identifier for clicking log in
 // Wait until log in is done
 // Activate the text field to compose a tweet
 // Type the tweet
 solo.enterText((EditText) solo.findViewById(""), "Bitbar");
 // Tweeting!

Want to test Android apps without scripts?

We offer a mobile device cloud that allows you to do AI-powered, codeless test automation. Sign up for a 30-day trial.

Wrapping up

Top 5 Android Testing Frameworks

Here we have listed top 5 testing frameworks for your daily Android builds, creation, and correction. Certainly, each of them has its pros and cons. And it depends on your goal and how comfortable you are with each framework. In general, Appium and Calabash are good cross-platform frameworks in testing both your Android and iOS versions at the same time. Espresso is a good choice if you are purely testing Android apps. Therefore, think about your testing need – functional testing, compatibility testing, UI testing, etc. – and pick up the right and best Android testing framework(s).

Calabash 101: Basics, Getting Started and Advanced Tips

Go through the basics of Calabash, how to create proper Calabash tests and how to make the most of them.


  • Darrell Henry

    Love it! Thanks for sharing! Would also love to let you know few frameworks
    for mobile testing which I believe you find it somewhat useful Check this

  • John Read

    Robotium & Appium are the best… thanks for posting this informative post with the code example, it helps alot to understand.
    best mobile phone application development

  • celin smith

    Thanks for sharing such a wonderful frameworks with elaborated examples. Apart from above frameworks i would like to add Snecha touch is one of the cross-platform mobile application development framework one cant afford to miss. Helps yo create mobile apps for Android, Iphone, Windows Phone and other Platforms

  • Ville-Veikko Helppi

    Here is a great blog about top iOS test automation frameworks. Check it out!

  • Impressive post !!


    How to set Geo Location on Google map by passing Latitude and Longitude with Appium

  • Lady Jane Bro

    But what is about Ubertesters? Our team is using it for the same purposes and it is in the TOp3 tools for testing

  • Duke Vukadinovic

    Great list guys! I’m particularly glad to see that you mentioned Espresso there, which is my favorite for quite some time.I love it because it allows me to automatically synchronizes my test actions with the user interface of my applications. It also ensures that my activity is started before the tests run and it waits until all observed background activities have finished.


    I liked that concluded chart 🙂

  • Lucid QA

    Very impressive post!!
    does anyone knows about an automation tools that can be use without having the phone connected to the computer in the proces?

  • william jones

    Thanks for sharing wonderful testing tools that will helpful in perform testing of various android devices. One can easily pick up the right android testing tool for functional testing, compatibility testing, UI testing, etc. Mobile app development become very popular these days and most of the people use android devices.

  • Finally a testing series. It would be nice if you could detail more how to separate concerns in an android app to be able to easily test the ui without the need of external resources, like network or content providers. Greetings! And please keep up with this series it’s a really needed topic to discuss.

  • Interesting read.Thanks for the post.

  • Nice blog author Lingkai Shao. Calabash framework basic syntax is clearly explained.

  • Hi Lingkai Shao! Very impressive post. Great Work!

  • Great Work!! Thanks for sharing the information!

  • Very impressive post Linkai Shao! Great work. Keep it up.

  • Milena Reddy

    Thanks for the impressive post.

  • I find this post very impressive. Thanks for sharing with us.

  • Nice post. Great list of tools. Thanks for sharing this.

  • Good to know about so many android automation framework. Amazing post.

  • Haven’t got the chance to use all of these frameworks but looking promising.

  • You can use Calabash in cross-platform frameworks for automating ios and android application with same feature. Nice Post.

  • tusharvyas

    Thanks great article I really like your article you can also visit Augmented Reality vs Virtual Reality Thanks

  • Great informative Post.

  • Your Top 5 Android Testing Frameworks With Code Examples are awesome and I am a Android Games developer.

  • Naira Thomos

    This post is really informative. Those tools are really useful to do the testing on the android devices. This post has made it easy to select the suitable testing tool for fucnionality and UI testing. Most of the people use android phone nowadays so mobile app development companies mobileapp development companies are in real demand nowadays.

  • Nice list of Android testing framework tools. I personally like Appium, it’s simple and easy to use.

  • Appium is an open-source mobile testing tool that supports both iOS and Android. It can be used to test any type of mobile app: native, web and hybrid. Appium is a cross-platform tool, meaning you can run the same test on different platforms.

    Hire Angularjs Developer

  • Hello, Very impressive post. Great Work!

    xamarin development company