---
description: Create, develop and learn- how to execute android testing framework automation test case throught this tutorial
title: Robotium Tutorial: Android Testing Framework with Example
image: https://www.guru99.com/images/robotium-tutorial.png
---

 

[Skip to content](#main) 

**⚡ Smart Summary**

Robotium is an open-source Android test automation framework that drives native and hybrid apps through their user interface, letting a tester script functional, system and acceptance scenarios that span several Android activities.

* 🔘 **Core class:** Solo exposes the click, search, drag and assertion methods that every Robotium test case calls.
* ☑️ **Black-box friendly:** Tests bind to UI components at run time, so minimal knowledge of the application source is required.
* ✅ **Four-step procedure:** Design the test specification, write the test program, execute it on a device, then collect the result.
* 🧪 **Worked example:** A complete HelloAndroidTest class checks the visible text, the current activity and the Start button.
* 🛠️ **Two run modes:** Launch tests from the IDE or from a terminal with the adb shell am instrument command.
* ⚙️ **Current status:** Robotium 5.6.3 remains the last release, so new Android projects usually pair or replace it with Espresso.

[ Read More ](javascript:void%280%29;) 

![Robotium Tutorial](https://www.guru99.com/images/robotium-tutorial.png) 

## What is Robotium?

**Robotium** is an Android testing framework that automates test cases for native and hybrid applications. Using Robotium, a developer can create robust automated GUI test cases for Android applications. A developer can also write functional, system and acceptance test scenarios that span several Android activities.

## Robotium Testing Framework

The standard Android testing framework carries the limitations listed below.

* Unable to handle multiple activities
* Test execution performance is slow
* Test cases are complex and hard to implement

The Robotium framework is the better choice for conducting testing on an Android application.

Robotium is an open-source framework and is considered an extension of the Android test framework. Using Robotium, a developer can create robust automated GUI test cases for Android applications. Moreover, a developer can write functional, system and acceptance test scenarios that span multiple Android activities.

The table below summarises the advanced features that separate Robotium from the plain instrumentation framework.

[](https://www.guru99.com/images/image017%284%29.png)

_Advanced features of Robotium_

## Robotium Test Case Classes

Robotium ships a small set of classes for testing, and the article's example imports the legacy `com.jayway.android.robotium.solo` package. These classes support test cases that span multiple activities, and `Solo` is integrated with `ActivityInstrumentationTestCase2`.

**Note:** current Robotium releases expose the same class under the shorter `com.robotium.solo` package, while the Maven coordinate stayed `com.jayway.android.robotium:robotium-solo`. Adjust the import to match the JAR version you actually add to the project.

The diagram below shows how the Solo class sits on top of the instrumentation test case.

[](https://www.guru99.com/images/image019%283%29.png)

_Integration of Robotium and ActivityInstrumentationTestCase2_

A tester can write test cases without knowledge of the application design, which makes the approach a form of [black box testing](https://www.guru99.com/black-box-testing.html). That is an outstanding advantage compared with the plain Android test case classes.

## How to Use Robotium

To use Robotium in your Android test project, you need to follow the steps below.

[](https://www.guru99.com/images/image021%283%29.png)

_How to use Robotium_

To guarantee the quality of your Android application, follow the four-stage procedure below.

* Design the test specification
* Develop the test program
* Execute the test case on the target device
* Collect the test result

The flow chart below places those four stages in order.

[](https://www.guru99.com/images/flow%5Fchart.png)

_Android application testing procedure_

## STEP 1) Design Test Specification

This is the first step in testing your application. In this step you define the target to be tested. An Android application has many targets that need to be tested, such as the UI, activities, components and services. Clearly defining the target helps you achieve wide test coverage.

* Plan the test types that should be conducted (unit test, functional test, system test).
* Design each [test case](https://www.guru99.com/test-case.html) for maximum coverage while keeping the number of test cases small. The more code you test, the higher the chance of early bug detection.

## STEP 2) Write Test Program

This section guides you through writing an Android test program using Android JUnit tests and Robotium. Assume you have already developed an Android program named HelloAndroid. This program has the functions described below.

* Display the text “Hello world!” on screen.
* Display a HelloAndroid message when the user presses the “Start” button.

The screenshot below shows the application under test running on a device.

[](https://www.guru99.com/images/hello%5Fworld.png)

_HelloAndroid application_

### System Requirements

* The Android platform ships with a pre-integrated JUnit 3 framework, which is what `ActivityInstrumentationTestCase2` builds on.
* To create an Android test project from Eclipse, your machine needs a working Android SDK installation.
* Install the current Android platform SDK rather than a pinned older release.

The screenshots in this walkthrough use Eclipse with the ADT plugin, which was the standard toolchain when the example was written. Eclipse ADT is no longer supported, so on a modern machine you would [download Android Studio](https://developer.android.com/studio) instead and reuse the same test code inside a Gradle module.

For the Robotium testing framework, download the Robotium library from the [Robotium project page](https://github.com/RobotiumTech/robotium).

### RELATED ARTICLES

* [iOS App Testing Tutorial ](https://www.guru99.com/getting-started-with-ios-testing.html "iOS App Testing Tutorial")
* [iOS Automation Testing with Xcode UI Framework ](https://www.guru99.com/ios-test-program-uiautomation-framework.html "iOS Automation Testing with Xcode UI Framework")
* [Selendroid Tutorial for Beginners with Example ](https://www.guru99.com/introduction-to-selendroid.html "Selendroid Tutorial for Beginners with Example")
* [Android Debug Bridge (ADB) Connect to Device over USB, WiFi ](https://www.guru99.com/adb-connect.html "Android Debug Bridge (ADB) Connect to Device over USB, WiFi")

### Create an Android Test Project

* Click File -> New -> Other
* Choose Android -> Android Test Project as shown in the figure below, then choose Next

[](https://www.guru99.com/images/select%5Fwizard.png)

_Create a new Android test project_

Write the name of your test project. By naming convention, the test project should be named “HelloAndroidTest”.

[](https://www.guru99.com/images/crearte%5Fandroid%281%29.png)

_Add the test project name based on the naming convention_

Choose the target application under test. In this case it is HelloAndroid, then click Finish.

[](https://www.guru99.com/images/test%5Ftargetjpg.jpg)

_Choose the target application under test_

### Create Test Suites

Based on your test specification, you now create test suites for your test program. You can choose from various [software testing](https://www.guru99.com/software-testing.html) frameworks. This tutorial uses the standard Android testing framework `ActivityInstrumentationTestCase2`. To test with Robotium, add the Robotium library file to a `libs` directory inside your project folder.

A test case defines the fixture used to run multiple tests. To define a test case, follow the program structure below.

* Implement a subclass of TestCase.
* Define instance variables that store the state of the fixture.
* Initialize the fixture state by overriding setUp().
* Clean up after a test by overriding tearDown().

The diagram below maps that structure onto the test program you are about to write.

[](https://www.guru99.com/images/image009%286%29.png)

_Test program structure_

package com.example.helloandroid.test;

import com.example.helloandroid.HelloAndroid;
import com.jayway.android.robotium.solo.Solo;
import android.test.ActivityInstrumentationTestCase2;
import android.widget.TextView;

public class HelloAndroidTest extends ActivityInstrumentationTestCase2 <HelloAndroid> {
    
	private HelloAndroid mActivity;
	private TextView mView;
	private String resourceString;
	private Solo solo;
	
	public HelloAndroidTest () {
		// TODO Auto-generated constructor stub
		super("com.example.helloandroid",HelloAndroid.class);	
	}
	
	 @Override
	protected void setUp() throws Exception {
		// TODO Auto-generated method stub
	//	super.setUp();
		 
	 	mActivity = this.getActivity();
		solo = new Solo(getInstrumentation(),getActivity());
		mView = (TextView) mActivity.findViewById(com.example.helloandroid.R.id.textview2);
		resourceString = mActivity.getString(com.example.helloandroid.R.string.hello_world);
		
	}
	 
	 @Override
	protected void tearDown() throws Exception {
		// TODO Auto-generated method stub
		//super.tearDown();
		solo.finishOpenedActivities();
	}
	
	public void testPrecondition() {
		assertNotNull(mView);
	}
	
	/* test Target application contains a text display "Hello World!"*/
	public void testSearchText() {
		assertEquals(resourceString,(String) mView.getText());
	}
	
	/* test HelloAndroid Activity on target application is exist*/
	public void testCurrentActivity() throws Exception  {
    	solo.assertCurrentActivity("wrong activity", HelloAndroid.class);
    }
    
	/* test Application UI contains "Start" button */
	/* send event click button to target application */
    public void testSearchButton() throws Exception {
    	boolean found = solo.searchButton("Start");
    	solo.clickOnButton("Start");
    	assertTrue(found);
    }
	

}

### Adding Test Cases

* In the same package as the test suite, create the TestCase classes.
* To test a certain activity, for example HelloAndroid, create a test case extending ActivityInstrumentationTestCase2<HelloAndroid>.
* Inside that class, the tester obtains the activity under test through the getActivity() method.
* Create a test for the activity freely by adding a method named “test + original method name”.
* Inside the test method, the tester can use Android [JUnit](https://www.guru99.com/junit-tutorial.html) functions to compare the actual value with the expected value. These methods are shown below.

The table below lists the assertion and interaction methods most often used in the two frameworks.

[](https://www.guru99.com/images/image010%285%29.png)

_Example methods of Robotium and the Android testing framework_

The test suite above verifies that the application GUI displays the text “Hello World!” and contains a button named “Start”.

## STEP 3) Run Test

After you finish writing your test program, run the test using the steps below.

* Connect an Android device to your PC, or start an emulator if no real device is available.
* In your IDE, right-click the test project and choose Run As → Android Unit Test.

The screenshot below shows the test run being launched from the IDE.

[](https://www.guru99.com/images/Run%5Ftest.png)

_Running the test program_

Besides running the test from the IDE, you can run it from the command line. In this test program the test package is `com.example.helloandroid.test`. In a Linux terminal, use the following command to run every test in that package.

`$ adb shell am instrument -w -e package com.example.helloandroid.test`

## STEP 4) Get Test Result

After the test executes, you collect the test results.

In this test program four test methods are executed. In the run below, all test cases passed.

[](https://www.guru99.com/images/image014%284%29.png)

_Test result output when all test cases pass_

If a test case fails, the output is displayed and shows you which test cases failed.

[](https://www.guru99.com/images/image016%284%29.png)

_Test result output when a test case fails_

## Source Code Examples

This article includes source code examples that help you follow the tutorial more clearly and pick up the technical detail quickly.

* [HelloAndroid](https://drive.google.com/uc?export=download&id=0B%5FvqvT0ovzHca3Fpb3RjN2Jfb2c): the application under test.
* [HelloAndroidTest](https://drive.google.com/uc?export=download&id=0B%5FvqvT0ovzHcYW5LTWdhQ2pseTg): the test program using the Android test framework.

If you want to compare Robotium with the other options in this space, see the [mobile application testing](https://www.guru99.com/testing-mobile-apps.html) guide, the [Appium tutorial](https://www.guru99.com/introduction-to-appium.html) and the roundup of [mobile app testing tools](https://www.guru99.com/mobile-testing-tools.html).

## FAQs

📅 Is Robotium still maintained in 2026?

Robotium 5.6.3 remains the last published release and active development stopped years ago. The framework still runs, and the artifact is still on Maven Central, but new Android projects normally choose Espresso, which Google maintains.

🆚 What is the difference between Robotium and Espresso?

Robotium is a black-box framework that binds to widgets at run time and needs little knowledge of the source. Espresso is Google’s white-box tool that synchronises with the UI thread and expects access to application code.

⚠️ What are the main limitations of Robotium?

Robotium drives one application at a time, cannot handle Flash or web content outside a WebView reliably, offers no built-in recording in the open-source JAR, and its reliance on deprecated instrumentation classes complicates modern Gradle builds.

📦 How do you add Robotium to a Gradle project?

Declare `androidTestImplementation 'com.jayway.android.robotium:robotium-solo:5.6.3'` in the module build file, or drop the [robotium-solo JAR](https://central.sonatype.com/artifact/com.jayway.android.robotium/robotium-solo/5.6.3) into `libs` and reference it as a file dependency.

📱 Can Robotium tests run on emulators and real devices?

Yes. Robotium tests are ordinary instrumentation tests, so the same APK runs on an emulator or a physical handset. Real hardware is preferred for gesture, sensor and performance checks, where emulator timing can differ.

🧪 Which test levels does Robotium cover?

Robotium suits functional, system and user acceptance scenarios at the UI level. It is not a substitute for unit tests, which run faster on the JVM, nor for the wider [types of software testing](https://www.guru99.com/types-of-software-testing.html) a release still needs.

🤖 How is AI used in Android UI test automation?

Machine learning is used for self-healing locators that survive layout changes, visual comparison that flags rendering regressions, and flaky-test detection that ranks reruns. The tooling reduces maintenance, but a human still decides what behaviour matters.

🚀 Can GitHub Copilot help write Robotium test cases?

[GitHub Copilot](https://docs.github.com/en/copilot/get-started/what-is-github-copilot) can scaffold a Solo setup, tearDown and assertion methods from an activity class. Review the suggestion carefully, because it may emit the legacy package import or assertions the app never satisfies.

#### Summarize this post with:

ChatGPT Perplexity Grok Google AI 

**Stay Updated on AI** **Get Weekly AI Skills, Trends, Actionable Advice.** 

##### Sign up for the newsletter

Subscribe for Free 

You have successfully subscribed.  
Please check your inbox. 

![AI-Newsletter]() Chosen by over **350,000+** professionals 

[Scroll to top ](#wrapper)Scroll to top 

× 

Toggle Menu Close 

Search for: 

Search

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.guru99.com/#organization","name":"Guru99","sameAs":["https://www.facebook.com/Guru99Official","https://twitter.com/guru99com"],"logo":{"@type":"ImageObject","@id":"https://www.guru99.com/#logo","url":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","contentUrl":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","caption":"Guru99","inLanguage":"en-US"}},{"@type":"WebSite","@id":"https://www.guru99.com/#website","url":"https://www.guru99.com","name":"Guru99","publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https://www.guru99.com/images/robotium-tutorial.png","url":"https://www.guru99.com/images/robotium-tutorial.png","width":"700","height":"250","caption":"Robotium Tutorial","inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://www.guru99.com/first-android-testing.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://www.guru99.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://www.guru99.com/mobile-testing","name":"Mobile Apps Testing"}},{"@type":"ListItem","position":"3","item":{"@id":"https://www.guru99.com/first-android-testing.html","name":"Robotium Tutorial: Android Testing Framework with Example"}}]},{"@type":"WebPage","@id":"https://www.guru99.com/first-android-testing.html#webpage","url":"https://www.guru99.com/first-android-testing.html","name":"Robotium Tutorial: Android Testing Framework with Example","dateModified":"2026-07-28T12:05:47+05:30","isPartOf":{"@id":"https://www.guru99.com/#website"},"primaryImageOfPage":{"@id":"https://www.guru99.com/images/robotium-tutorial.png"},"inLanguage":"en-US","breadcrumb":{"@id":"https://www.guru99.com/first-android-testing.html#breadcrumb"}},{"@type":"Person","@id":"https://www.guru99.com/author/thomas","name":"Thomas Hamilton","description":"I am Thomas Hamilton, a seasoned professional in software testing, specializing in crafting comprehensive guides to help you master your software testing skills.","url":"https://www.guru99.com/author/thomas","image":{"@type":"ImageObject","@id":"https://www.guru99.com/images/thomas-hamilton-author-v2-120x120.png","url":"https://www.guru99.com/images/thomas-hamilton-author-v2-120x120.png","caption":"Thomas Hamilton","inLanguage":"en-US"},"worksFor":{"@id":"https://www.guru99.com/#organization"}},{"articleSection":"Mobile Apps Testing","headline":"Robotium Tutorial: Android Testing Framework with Example","description":"Create, develop and learn- how to execute android testing framework automation test case throught this tutorial","keywords":"mobile","speakable":{"@type":"SpeakableSpecification","cssSelector":[".entry-title",".summary"]},"@type":"Article","author":{"@id":"https://www.guru99.com/author/thomas","name":"Thomas Hamilton"},"dateModified":"2026-07-28T12:05:47+05:30","image":{"@id":"https://www.guru99.com/images/robotium-tutorial.png"},"copyrightYear":"2026","name":"Robotium Tutorial: Android Testing Framework with Example","subjectOf":[{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"Is Robotium still maintained in 2026?","acceptedAnswer":{"@type":"Answer","text":"Robotium 5.6.3 remains the last published release and active development stopped years ago. The framework still runs, and the artifact is still on Maven Central, but new Android projects normally choose Espresso, which Google maintains."}},{"@type":"Question","name":"What is the difference between Robotium and Espresso?","acceptedAnswer":{"@type":"Answer","text":"Robotium is a black-box framework that binds to widgets at run time and needs little knowledge of the source. Espresso is Google's white-box tool that synchronises with the UI thread and expects access to application code."}},{"@type":"Question","name":"What are the main limitations of Robotium?","acceptedAnswer":{"@type":"Answer","text":"Robotium drives one application at a time, cannot handle Flash or web content outside a WebView reliably, offers no built-in recording in the open-source JAR, and its reliance on deprecated instrumentation classes complicates modern Gradle builds."}},{"@type":"Question","name":"How do you add Robotium to a Gradle project?","acceptedAnswer":{"@type":"Answer","text":"Declare androidTestImplementation 'com.jayway.android.robotium:robotium-solo:5.6.3' in the module build file, or drop the robotium-solo JAR into libs and reference it as a file dependency."}},{"@type":"Question","name":"Can Robotium tests run on emulators and real devices?","acceptedAnswer":{"@type":"Answer","text":"Yes. Robotium tests are ordinary instrumentation tests, so the same APK runs on an emulator or a physical handset. Real hardware is preferred for gesture, sensor and performance checks, where emulator timing can differ."}},{"@type":"Question","name":"Which test levels does Robotium cover?","acceptedAnswer":{"@type":"Answer","text":"Robotium suits functional, system and user acceptance scenarios at the UI level. It is not a substitute for unit tests, which run faster on the JVM, nor for the wider types of software testing a release still needs."}},{"@type":"Question","name":"How is AI used in Android UI test automation?","acceptedAnswer":{"@type":"Answer","text":"Machine learning is used for self-healing locators that survive layout changes, visual comparison that flags rendering regressions, and flaky-test detection that ranks reruns. The tooling reduces maintenance, but a human still decides what behaviour matters."}},{"@type":"Question","name":"Can GitHub Copilot help write Robotium test cases?","acceptedAnswer":{"@type":"Answer","text":"GitHub Copilot can scaffold a Solo setup, tearDown and assertion methods from an activity class. Review the suggestion carefully, because it may emit the legacy package import or assertions the app never satisfies."}}]}],"@id":"https://www.guru99.com/first-android-testing.html#schema-1153145","isPartOf":{"@id":"https://www.guru99.com/first-android-testing.html#webpage"},"publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://www.guru99.com/first-android-testing.html#webpage"}}]}
```
