Top 5 Android Application Testing Framework

Did you know?
There are 300+ Million Android devices across the globe
850,000 daily Android activations
Google play has over 450,000 Android Apps available

Take a look few key App Highlights to discuss further

Google’s Android ecosystem is continuing to expand rapidly. It is evident that new mobile OEMs are emerging in every corner of the world adds in different screen sizes, ROM/firmware, chipsets, etc.

For Android developers/testers, it becomes relatively difficult to cope up with the fragmentation.

Luckily, Android developers/Testers have unlimited access to some advanced cloud-based mobile testing solution, like Testdroid Cloud, for the Large-Scale Automation of real devices for quality assurance.

Indium follows a process-oriented approach for the successful deployment of Test Automation

Read More

Also, the emergence of different Android testing frameworks has substantially relieved Android developers’/Tester lives.

In this blog, we are going to discuss five most used Android testing frameworks and break down the basics and code examples of each.


Definitely, Robotium was once the most widely used Android testing framework in the early days of the Android world.

It is similar to Selenium in Android and makes testing API simpler.

Robotium is an open source library extending JUnit with abundant useful testing methods for Android UI testing.

It offers powerful and robust automatic black-box test cases for Android apps (native and hybrid) and web testing. With Robotium we can write function, system and acceptance test scenarios, and test applications where the source code is available.


// 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(“”), “Testdroid”);
// Tweeting!

For convenience, Testdroid Recorder is used. It is an amazing recording tool built with Robotium for test script creation.

By performing actual actions on the real device, the tool records every step or action taken and converts it to Javascript for further modification.

In addition to that, it is also entitled to download and utilize the extension Library – ExtSolo.

It includes useful methods that have not been merged into Robotium, for instance:

  • Automatic scaling of clicks for any resolution
  • Multi-path drags
  • Automatic test failure screenshots
  • Mock locations
  • Change device language
  • WiFi control


Although Robotium is a good yet basic framework, UIAutomator offers Android apps and games testing.

Google’s test framework allows user interface (UI) testing of native Android apps on one or more devices.

Another advantage of UIAutomator is that it runs JUnit test cases with special privileges. This means that the test cases can span across different processes. It also provides five different classes to use, including

UiCollection | UiDevice | UiObject | Uiscrollable | UiSelector

But, it only works on Android devices with API level 16 or higher. Another downside of UIAutomator is that the tool doesn’t support web view, with no way for direct access to Android objects.


// 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 #Testdroid!”); // Tweeting!
new UiObject(new UiSelector().text(“Tweet”)).click();


Espresso is the latest Android test automation framework that got open-sourced by Google. It is now available for developers and testers to beat out the UIs.

Espresso has an API which is small, predictable, easy to learn and built on top of the Android instrumentation framework.

Is Your Application Secure? We’re here to help. Talk to our experts Now

Inquire Now

Also, Android UI tests can be quickly written with it. It supports API level from 8 (Froyo), 10 (Gingerbread), and 15 (Ice Cream Sandwich) and afterwards.

It’s quite reliable, synchronizing with the UI thread is fast, because, there is no need for any sleeps (test run on same millisecond when an app becomes idle).
But it does not support web views.


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(”#Testdroid”)));
// Tweeting!
.getIdentifier(“”, null, null))).perform(click());


Calabash is a cross-platform test automation framework for Android and iOS native and hybrid applications.

Calabash has easy-to-understand syntax, which enables even non-technical persons to create and execute automated acceptance tests for apps on both of these mobile platforms.

Calabash’s tests are first described in Cucumber and then it is converted to Robotium or Frank in run time. It supports almost 80 different natural language commands (controllers), and new controllers can be implemented to it in Ruby or Java.


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 “Testdroid” into field with id “edit”
Then I press view with id “composer_post”


Appium is a mobile test automation framework (and tool) for native, hybrid and mobile-web apps for iOS and Android.

It uses JSONWireProtocol 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

One of the biggest advantages of Appium is that you can write Appium scripts can be written in almost any programming language (e.g. Java, Objective-C, JavaScript, PHP, Ruby, Python or C#, etc), freedom to select tools, compatibility across the most important platforms (Android and iOS), freedom to install and configure devices to test.

Also, familiarity with Selenium makes it easy to use Appium in mobile app testing. They use the same WebDriver and the desired capabilities are also used in the same way. Configuring an application to run on Appium has a lot of similarities to Selenium.


# 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(”#Testdroid is awesome!”)
# press the Send button
# exit


Here are top 5 android testing frameworks for daily Android builds, creation, and correction. Certainly, each of them has its own pros and cons.

Appium is good in testing both your Android and iOS versions at the same time. If it is for a loyal Android developer with only Android-version app, for instance, then using Robotium is a good idea too.

Also, Testdroid Recorder will definitely save lots of time and money and It’s free. Therefore, think about testing need – functional-testing, compatibility testing, UI testing, etc. – and select the right and best Android testing framework(s).

Thanks for Reading!