Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Has anyone used Robotium or Calculon for testing Android apps?

Has anyone used Robotium or Calculon for testing Android apps? Are they useful? Any recommendations on which is better?

like image 824
Bob McCormick Avatar asked Feb 19 '10 22:02

Bob McCormick


People also ask

What is Robotium in Android application?

Robotium is an open-source test framework for writing automatic gray box testing cases for Android applications. With the support of Robotium, test case developers can write function, system and acceptance test scenarios, spanning multiple Android activities.

Where can we execute Robotium test cases?

Robotium Test cases can be executed on Android Emulator as well as the Real device, we don't need to write any specific configuration code to run Robotium test cases on the Real device. Robotium Can be easily written in the Maven project also, and it can be run through continuous integration tools.

How to use Robotium?

Test an App with RobotiumStep 1 − Create a test Project in the Android Studio named as “RobotiumTest”. Choose all the default options until you reach to the main page. Step 2 − Copy the Robotium jar file into the Lib folder of the project. Step 3 − Add the dependency in build.


1 Answers

I'd go with Robotium since Calculon is still in very early stages. Here's a comment from Calculon's author:

Well, currently it’s just a bunch of source files which I pulled out of another project...Note that this library is still a very early prototype. Its API will probably change. Source

I've played with Robotium today, it definitely makes writing functional tests fun. To give you an idea, here are a few method highlights from the API:

  • clickOnButton, clickOnText
  • enterText
  • getCurrentButtons, getCurrentEditTexts, getCurrentImageViews, getCurrentSpinners, getCurrentTextViews
  • pressMenuItem, pressSpinnerItem
  • searchText, searchEditText, searchButton

Here is a code sample from the Getting Started Guide:

  public void testTextIsSaved() throws Exception {
    solo.clickOnText("Other");
    solo.clickOnButton("Edit");
    assertTrue(solo.searchText("Edit Window"));
    solo.enterText(1, "Some text for testing purposes")
    solo.clickOnButton("Save");
    assertTrue(solo.searchText("Changes have been made successfully"));
    solo.clickOnButton("Ok");
    assertTrue(solo.searchText("Some text for testing purposes"));}

Definitely give it a try if you're going to write ActivityInstrumentationTestCase2 classes. Check out the Getting Started guide for instructions.

like image 72
Sarp Centel Avatar answered Sep 26 '22 06:09

Sarp Centel