Home » ExtSolo Library – to extend your Robotium test automation

ExtSolo Library – to extend your Robotium test automation

Today, I found a really nice library extension for Robotium. The name of the library is ExtSolo and stands for Extension Solo. The name stands for itself, it extends the known solo object provided by Robotium.
The library is developed by the guys from bitbar, the company behind testdroid.

If you check the provided API documentation, you find some really useful methods to integrate them into your Android test automation framework. There are methods like:

  • changeDeviceLanguage(java.util.Locale locale)
  • fail(java.lang.String name, java.lang.Object e)
  • setGPSMockLocation(double latitude, double longitude, double altitude)
  • turnWifi(boolean enabled)

I really like the methods to mock the current GPS location of the device or to turn of the wifi during the test execution, to see how the app handles the network loss. All you have to do is to include the provided jar file to your Android Robotium project, to import the ExtSolo package and to create an Extsolo object.


See the code example to turn wifi off and on again:

import com.robotium.solo.Solo;
import com.example.android.notepad.NotesList;
import android.test.ActivityInstrumentationTestCase2;

import com.bitbar.recorder.extensions.ExtSolo;

 public class NotePadTest extends
ActivityInstrumentationTestCase2<NotesList> {

   private ExtSolo solo;

   public NotePadTest() {
      super(NotesList.class);
   }

      @Override
   public void setUp() throws Exception {
       // normal solo object: solo = new Solo(getInstrumentation(),
getActivity());

      solo = new ExtSolo(getInstrumentation(),
         getActivity(), this.getClass().getCanonicalName(), getName());
   }

      @Override
   public void tearDown() throws Exception {
      solo.finishOpenedActivities();
   }

      public void testAddNote() throws Exception {
      solo.clickOnMenuItem(“Add note”);
      solo.turnWifi(false);

      //Assert that NoteEditor activity is opened
      solo.assertCurrentActivity(“Expected NoteEditor activity”,
         NoteEditor”);

      solo.turnWifi(true);
   }
}

I just tried the the wifi mode and I think this is pretty useful.

Thanks to the guys from bitbar.

The complete library documentation as well as the jar files can be found here: http://docs.testdroid.com/_pages/extsolo.html

Happy Testing!

By Daniel Knott