5 Most Used Android Testing Frameworks

As time goes by, Google’s Android environment continues to grow. As we can observe, new mobile OEMs are being launched in different locations on the globe, with different screen sizes, chipsets, ROM/Firmwares, etc. It’s getting harder for the Android developers to adapt with this fragmentation.

Android and iOS developers are fortunate to have limitless access to some advanced could-based solution, like TestDroid Cloud. They will be able to run automated tests on a large scale for real devices to be assured of its quality. Android developer’s life has now become a little easier because of the rise of the Android testing frameworks.

These are the top 5 Android testing frameworks with example codes:

  • UIautomator
  • This testing framework allows you to do more testing on Android apps and games. The test framework of Google permits you to test the user interface of your Android apps on one or more devices. Uiautomator runs JUnit test cases with special benefits that means that your test cases can span across different pprocedures. This is quite beneficial for you. Developers can use different classes that is provided by this which includes :
  • android.uiautomator.core.UiCollection;

This only works provided that your Android devices have API level 16 or higher. This does have a disadvantage. Uiautomator doesn’t support webview which means that your Android objects is not accessible directly.

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()) {
signInButton.click(); // 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();



  • Calabash
  • This is a cross-platform test automation framework that can be used on android, iOS native and also on some hybrid applications. The Calabash syntax is easy to understand that even the non-technical people can create and execute automated acceptance test on both mobile platforms. Cucumber describes the test on Calabash and then it is converted to Robotium or Frank in its running time. New controllers can be made by using Ruby or Java and this supports over 80 different natural language commands (controllers).

Code example:


<pre>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"



  • Espresso
  • This is the latest Android test automation framework that became open source due to Google’s decision. This is made available to all developers and enable them to test their UIs using this. This have an API that is small, can be learned effortlessly , can be predicted, and is built on top of Android instrumentation framework. Using Espresso, you can write concise and reliable Android UI tests. This is supported on API level 10 (Gingerbread), 15 (Ice Cream Sandwich), 8 (Froyo) and later levels. Just like Uiautomator, this doesn’t support webviews.

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("com.twitter.android:id/sign_in", null, null))).perform(click());
// R class ID identifier for entering username
.getIdentifier("com.twitter.android:id/login_username", null, null))).perform((typeText("username")));
// R class ID identifier for entering password
.getIdentifier("com.twitter.android:id/login_password", null, null))).perform((typeText("password")));
// R class ID identifier for clicking log in
.getIdentifier("com.twitter.android:id/login_login", null, null))).perform(click());
// Activate the text field to compose a tweet
.getIdentifier("com.twitter.android:id/menu_compose_tweet", null, null))).perform(click());
// Type the tweet
.getIdentifier("com.twitter.android:id/edit", null, null))).perform((typeText(”#Testdroid")));
// Tweeting!
.getIdentifier("com.twitter.android:id/composer_post", null, null))).perform(click());



  • Appium
  • This is a mobile test automation and tool for hybrid, native and mobile-web apps for Android and iOS. To internally communicate with Android and iOS apps using Selenium’s WebDriver, it uses JSONWireProtocol.

This supports Androind through the following:

-uiautomator (API 16 or higher)

-Seledroid (API level lower than 16)

-iOS through UI Automation

-Mobile web Selenium driver for Android and iOS

You can write Appium scripts on using any programming languages such as Objective-C, PHP, Java, Python, Ruby, C#, etc and compatibility across the most important platforms such as Android and iOS. You are given freedom to select tools and to install and configure devices to test and more. For those who are familiar with Selenium, using Appium will probably be easy for you in mobile app test. Appium and Selenium uses the same WEbDriver and DesiredCapabilitites  which is used on the same way. In configuring an application to run, Appium and Selenium has a lot of similarities.

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



  • Robotium
  • In the early days of the Android world, Robotium was once the most widely used to Android testing framework. This has a similarity with Selenium in Android that makes testing API easier. This is an open source library that extends JUnit with numerous of useful methods used for Android UI testing. For Android apps (native and hybrid) and web testing, this gives a powerful and strong automatic black-box test cases.  Using Robotium will enable you to write function, system, test scenarios, and test applications where the source code is accessible.

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("com.twitter.android.R.id.login_username"),"username");
// R class ID identifier for entering password
solo.enterText((EditText) solo.findViewById("com.twitter.android.R.id.login_password"),"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("com.twitter.android.R.id.edit"), "Testdroid");
// Tweeting!




A recording tool was built using Robotium which is called Testdroid recorder for creating test script. This records every action you take while performing actions on your real device and then converts it to Javascript for any other modifications.

Additionally, you should fully download and use the extension Library which is the – ExtSolo.

These are the following useful tools that haven’t been incorporated in Robotium :

  • Screenshots that will be taken automatically on test failure
  • A change on device language
  • Multiple path drags
  • Scales of x and y clicks for any resolution will be automatic
  • Artificial locations
  • Control over the WiFi connection

Pros and Cons on the top 5 android testing Frame works


As shown on the image, Appium is good in testing both Android and iOS versions simultaneously. Though, if you are an Android developer that only has Android-version then Robotium is also a good choice. To definitely save time and money in generating test scripts, you can rely on the TestDroid recorder, fyi, it’s free. Therefore we conclude, you should take note about your testing needs whether it is on compatibility testing , Ui testing , functional testing etc. After you take note of everything, you can then now choose the right and the best Android testing Framework for you.

Leave a Comment: