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 :)

Serialization types with implementation in C#.NET

Hi Everyone,

Today, I am coming up with the topic of “serialization in .net framework” .  There are three types of serialization techniques present in the .net framework. They are briefly explained as follows:

1) Binary Serialization
2) XML serialization
3) Soap Serialization

In this article, I will not focus on the theoreotical part rather will focus on how you can implement these concepts in the simple application.

Let us consider a sample application of Notepad Font. As we know, when we open a notepad application, we see the font of the text which we have set earlier at the last execution of notepad.

( Please note: This is not relevant to a particular file. Every file is opened in the same font which is set earlier in notepad )

Following is the code for binary serialization in the .cs file:

MainFont obj = new MainFont();
obj.Fnt =  RTBArea.Font;

FileStream fs;

fs = new FileStream(@”font.dat”, FileMode.Create, FileAccess.Write,  FileShare.Read);

BinaryFormatter binF = new BinaryFormatter();

binF.Serialize(fs, obj);

fs.Close();

In the above code, MainFont is the class whose namespace is as follows:

namespace Notepad
{
    [Serializable]
    public class MainFont
    {
              private Font fnt;
              public Font Fnt
             {
                      get { return fnt; }
                      set { fnt = value; }
             }
     }
}

Using the above code, you will be able to serialize the font set by the user in your notepad ( i.e. Rich Text Box )

Now, we have to deserialize the object which we have saved earlier.

To deserialize the object, write the following code in the load event of the application:

FileStream fsw;
            MainFont mf = new MainFont();

             fsw = new FileStream(@”font.dat”, FileMode.Open, FileAccess.Read,FileShare.Read);

             BinaryFormatter binF1 = new BinaryFormatter();
             mf = (MainFont)binF1.Deserialize(fsw);

            RTBArea.Font = mf.Fnt;

By using the above code, it will deserialize the font object present in the font.dat file and the font is assigned to the RTBArea font.

I have provided with the code for the Binary serialization in this article. If you want to implement soap and xml serialization, then you just have to use the XMLSerializer class and use references “System.Runtime.Serialization.Formatters.Soap” and “System.Runtime.Serialization.Formatters.xml”.

Note: For using the XMLSerializer, the members of the class should be public.

Enjoy :)

Internship Experience at ZSoftware Inc

Hi Everyone,

I just completed my 1 year 8 months as an intern at ZSoftware Inc  and it was one of the awesome and memorable experience in my life. I worked on several other projects before joining ZSoftware during my engineering, but the quality and user interoperability of the software, I learnt at ZSoftware. :)

[Snapshot: { Names from left: Myself, Akshay Zadgaonkar, Sarang Mude }]

I worked on a project which analyzes and maintains complete records related to cricket tournaments, series, matches and other club events and provides the feature of giving an input ball by ball in the live cricket match.

Some of the features of Cricket Software:

  •  Simplified addition of new players and teams.
  •  Automatic sequence maintaining in Team, Players.
  •  Console for Real Time Data input using Hot-Keys.
  •  Maintaining match history.
  •  Projectable Score Board.
PS:  All features are *not* mentioned here as the software is still in testing phase at ZSoftware Inc.
It is the Quality that matters not the Quantity. This proverb is best suited for Zadgaonkar’s Software Private Limited.

   [Snapshot: { Sarang Mude, Myself, Akshay Zadgaonkar }]

Learnt a lot, Its OK! But mostly importantly, I enjoyed a lot at ZSoftware Inc. We used to have some awesome( weird also :P ) conversations during the office timings, not like the other companies.  It was Fun :D

Principle was like : “Party hard, work harder”. :D

I wont forget all the jokes we played on each other. Akshay sir and Sarang sir’s eagerness about knowing whose my girlfriend and all..lol! and I used to convince them with my convincing power ;) Had awesome fun indeed :D

Now that, I signed off from ZSoftware Inc, I am gonna join Persistent Systems Ltd in Nagpur only from 15th September as a Software Engineer in the Development track. So, yes! Kinda excited but professional experience is in my pocket ;)

I think Persistent System Ltd will be a little strict… :P So, don’t expect blogposts in the small intervals. But surely will update blog when I get time.

So, @MsWizKid signing off, Cheers!

[ Snapshot taken at ZSoftware Office ]

Enjoy :)