Design Data Driven Framework around Robotium

In my last tutorial we tested Test Android apk file with Robotium. Simple Android Calculator’s apk was used with some specific input values. Now in this tutorial we are extending testing to Data Driven Testing approach under Robotium. Many automate testers may have worked on Data Driven Testing Framework for web sites or Desktop applications.Link
There are many Data Driven Frameworks available, but to save time I have tried to develop me own data driven framework. It may not mature enough but we can make it more intelligent by extending it.

1. Data Driven Testing Architecture

I am going to define my test scenarios into a csv (comma separated version) file and my script file will

* Read input from TestData.csv file
* Enter each ‘First Value’ column data in first edit field
* Enter each ‘Second Value’ column data in second edit field
* Click on Multiply field each time
* Verify Resultant value

To create a data driven development we will go through following steps

* Create Test Data
* Push Test Data into Emulator
* Import jar file
* Create Test Script (read data and assign values to AUT(application under test)
* Execute Test scenarios
* View Test Results

We will apply Data Driven testing approach on Android Simple Calculator. In which we enter two values and on clicking Multiply button it will show their resultant value. We will use Test Android apk file with Robotium project for Data Driven Testing implementation.

2. Create Test Data

We can create any combination of First and Second Value to test our Simple Calculator on Android. First Value represents the values for First Editfield and Second Value represents the Second Editfield in Android Simple Calculator. Execute column will allow the script to execute specific scenarios only.

3. Push Test Data into Emulator

Robotium will run our test script into emulator, for proper implementation of Data Driven Testing we need to make Test Data file accessible for emulator.

Load emulator, from eclipse Load DDMS interface. From Project Explorer tab navigate to the AUT package (our Android Simple Calculators package is com.calculator) and expand it to files category. It will be empty, we will push our Test Data file into files directory and then our script will be able to read TestData contents with emulator.

From top right section click on push icon and browse the TestData file from your computer.

It will show the pushed test data file into files directory like below

4. Import JXL jar file

Our TestData file is in CSV format so we need to import necessary jar file to read contents, there may be multiple API available on Internet, I will be using JXL, it is available on following link.

After successfully download import that jxl.jar file into project build path.

5. Create Test Script

From Test Android apk file with Robotium project open the TestApk.java file and replace the existing code with one (same file name) in shared project code.

6. Run Test Script

Now its time to run our test script, From eclipse right click on project, select Run As and then click on Android JUnit Test. Wait for some time it will show the progress in console bar like below


System will load Android Simple Calculator app into emulator and start to read TestData file and enter First and Second Values into calculator and asserts resultant values. I have put (System.out.println) code to print results, you need to load LogCat interface and results will be visible there in logCat window like below,

After completing execution eclipse will show successful script execution like below.

7. View Results

After successful execution test script will create and write results into txt file and that file will be visible into Project Explorer of DDMS.


Click on pull icon top right to put that file and view it. Results of all test scenarios will be visible into TestResultData file.

Note: This is the basic Data Driven Testing framework around Robotium. There are many things which can be implemented in better way. I have tried to develop it in simplest way. Its up to the test engineer to use it in his/her own way. We can make it as much intelligent as we need.

Download sample project code with TestData file