Robotium – Open Source Testing Framework For Android

 

This post is on the topic ‘Robotium – Testing Framework for Android’. I had worked on Robotium framework sometime back so just wanted to share the information related to the same with you all.

What is Robotium?

Robotium is a test framework created to make it easy to write powerful and robust black-box test cases for Android applications.

 

  • With the support of Robotium, test case developers can write function, system and acceptance test scenarios, spanning multiple Android activities
  • Robotium has full support for Activities, Dialogs, Toasts, Menus and Context Menus
  • Robotium is a Free tool, can be used by individuals and Enterprises
  • Robotium is a “Black Box” testing tool that is able to simulate and automate user interaction such as touching, clicking, text entry and any other gesture that is possible on a touch supported device
  • The tests could either be executed on the Android simulator (AVD – Android Virtual Device) or on a real device
  • Robotium is built on the Java programming language and the JUnit 3 test framework
  • Robotium can be used both for testing applications where the source code is available and applications where only the apk is available

 

Since the Robotium test tool is open source, no cost is associated with this.

Benefits of Using Robotium:

 

  • Easy to write, shorter code. Minimal time needed to write solid test cases
  • You can develop powerful test cases, with minimal knowledge of the application under test
  • The framework handles multiple Android activities automatically. Readability of test cases is greatly improved, compared to standard instrumentation tests
  • Automatic timing and delays
  • Automatically follows current Activity
  • Automatically finds Views
  • Automatically makes own decisions (ex: When to scroll etc.)
  • No modification to Android platform
  • Test execution is fast
  • Test cases are more robust due to the run-time binding to GUI components
  • Integrates smoothly with Maven or Ant
  • With the newly released Robotium 4.0, it has full support for hybrid applications. Hybrid applications are applications that use WebViews to present the HTML and JavaScript files in full-screen, using the native browser rendering engine

 

Robotium Features:

 

  • Screenshots can be captured inside Robotium
  • Robotium can be run without source code
  • It’s possible to generate code coverage reports for your Robotium tests
  • Robotium is able to detect the contents of a Toast on the screen
  • Localised strings can be used (Needs source code)
  • Robotium test can be run from the command line
  • Robotium offers many methods that react to different graphical elements within an Android app, such as

 

clickOnText(“Secure Login”);

 

clickOnButton(“Save”);

 

searchText(“Logout”);

 

goBack();

 

getButton();

 

isRadioButtonChecked();

 

  • With these simple methods, robust automated tests can be implemented really quickly. By combining them with JUnit, you then have additional ways of checking values or user interactions on the device for the correct response, which in turn makes these tests even more powerful

 

Limitations:

 

  • Cross Activities testing, Robotium is able to work only with same certificate app, otherwise you will get inject events exception (e.g. you are not able to do clicks on screen keyboard)
  • Robotium has no mechanism to handle expected/unexpected alerts/popus/dialogues. For example, iOS Javascript tests has very simple boolean flag and callback for handling alerts
  • Robotium has big problem with auto scrolling methods. For example, if you are looking for the text, which is not shown, Robotium will stack in the end of the scroll view and make assertTrue(false) to stop scrolling
  • Robotium has assertTrue(false) logic for reporting problems/unexpected situations instead of returning some Enum value or boolean (success/fail) so for a good stress tests which are run 24/7, you need to add your own methods which will not stop test, just handle ‘method fail to click x y’ result value
  • The scope of test cases in Robotium is limited to a single application and does not support for more than one application. Test project is always locked with a target package, which need to be tested and going outside of the package is not allowed
  • Android native API’s (Contacts, Widgets etc.) used in the Android application cannot be tested using Robotium. While executing test, if focus is switched to Native application, it will not come back to the Test application and Test will fail
  • Robotium is not able to handle the flash or web components. It only works with android components. You could send in clicks by using clickOnScreen() or assert that a certain Activity is shown but that is all. You will not be able to write tests where you verify or work with the web or flash components
  • Test Execution is very slow
  • Test cases are complex to implement
  • Not able to handle multiple activities
  • Robotium does not support flash and web based applications.
  • Robotium does not work on Canvas.

 

Future Enhancements:

 

  • Robotium Remote Control similar to Selenium RC
  • Integration with BDD tools such as cucumber
  • Automatic measurement of user interface test coverage
  • Generate screenshots on failure
  • Multiple device support

 

To get started with implementation, you can refer this link.

Talking off the topic, It’s great to be back on the blog after a long long time. I will make sure you get the latest updates on time :)

@MsWizKid signing off!

Enjoy :)

Easier .NET Development using Visual Studio LightSwitch 2011

Hi guys,

I recently attended one session on Microsoft Visual Studio LightSwitch 2011 at Persistent Systems Limited and found it very interesting and helpful. You can get all the information about LightSwitch from here .

According to me, some of the important features of Microsoft Visual Studio LightSwitch 2011 which I liked are as follows:

1) Easier facility to add data source and retrieve data from MS SQL Server, MS SQL Azure, MS SharePoint and Windows Communication Foundation

2) Business friendly data types like EmailAddress and PhoneNumber are present which are very helpful

3) One can create screens for your data quickly using shortcuts present in the action bar

4) One can choose from already present common screen templates and match the screen to the appropriate data source

5) Edit screen layout using a Tree Control

6) Screens automatically create input field for the entity model they are matched to

7) Business data types enable additional validation and functionality without writing a single code

8) Export to Microsoft Excel is directly available

9) It enables non-programmers to develop professional, quality business applications

10) Customizable templates enable new and creative user experiences

11) LightSwitch features support for many devices—including touch-screen support—is built in

12) If you have already built any desktop application and in a need to convert it to web application then it is very easy to convert that desktop application with a single button click and your web application is ready to deploy.

Different shells are available for the applications in LightSwitch so that at any point of time, one can easily change the UI as quickly as possible with a single button click.

The limitation of LightSwitch which I felt is that UI is completely dependant on the shell. Different templates could not be added in the same application at one point of time.

I am finding it very much useful and try to work with it once a week. To download Microsoft Visual Studio Lightswitch, kindly use this link.

Enjoy :)

Just another awesome server – Team Foundation Server 2010

Hi Everyone,

I recently attended a seminar on topic “Visual Studio 2010 features and Team Foundation Server 2010″. It was taken by Mr. Sinjinth HR from Microsoft. He works in the Visual Studio Team. I really enjoyed the seminar and the contents of the seminar were also very useful specially the demos.

Have anybody previously used the Performance wizard in Visual Studio 2010? If you didn’t, then please go through it. It is really awesome to get the statistics of your code and it also tells you about the time complexity and other performance based attributes.

Some of the features of the TFS 2010 explained in webinar were:

1) Work Item Tracking

2) Version Control

3) Build Automation

4) Reporting ( Different charts )

5) Project Management

The concepts regarding the Shelving and Branching are really good. He explained it very briefly. If you don’t know about the features of Team Foundation Server 2010, then you can see video attached below. This video explains concept in a better way rather than me writing all the learnt stuff here. :P

Enjoy :)