My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Featured
Downloads
Links

Loquacious Droid

Loquacious Droid is a functional testing framework for the Android platform that uses a fluent DSL. This is the third implementation of the Loquacious testing framework. Thus, the DSL used is heavily based on Python's Loquacious-Snake and PHP's Loquacious-Elephant that were developed by the same authors.

Inspired and built with parts of the Robotium project, it is intended to be used as an alternative to Robotium.

An test example taken from a sample Project

public void testThatAnReminderCanBeDeletedByTheContextMenuBroughtByALongClickOnTheReminder() throws Throwable{
		

    havingAlreadyAddedToHisReminders(  aReminder()
                                       .withThisTitle("Pick up the kids")
                                       .andThisDescription("At school on friday")
                                       .build()
                                     );

    aUserOfMyReminderAppGoesToTheHomePage();
		
    aUserOfMyReminderApp.looksAtThisListView(R.id.list_of_my_reminders)
                        .andPressesForALongTimeTheElementThatContainsThisText("Pick up the kids")
		        .andThen()
                        .waitsForThisTextToAppear("Delete this reminder");
		              
    aUserOfMyReminderApp.clicksTheElementsContainingThisText("Delete this reminder");
		
    aUserOfMyReminderApp.waitsForThisTextToDisappear("Delete this reminder")
		        .andThen()
                        .looksAtThisListView(R.id.list_of_my_reminders)
		        .andItShouldNotContainThisText("Pick up the kids");
		
}

How to get started

Using IntelliJ Idea

  1. Create a new module in your project that will hold your scenarios/system tests
    • Click on File -> New Module
    • Select create Module from scratch
    • Select Android module and give it an appropriate name
    • Create source directory
    • Select your target Platform and make sure you select Test in that same window. The pick your application under test.
    • Finish
  2. Download the Loquacious Droid jar
  3. Add it to your dependencies.(Press F4 in your project explorer on your test project)
  4. Create your first scenario test class.
  5. You can then run the test by right clicking on the package containing your tests. The go in the run section and run your tests.

Your first test class could look a little like this :

public class SystemTests extends ActivityInstrumentationTestCase2<HomePageActivity> {

    private AndroidUser anAndroidUser;

    public SystemTests(){
        super("com.package.to.your.homepage.activity", HomePageActivity.class);
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        anAndroidUser = new AndroidUser(getInstrumentation(),getActivity());
    }

    @Override
    public void tearDown() throws Exception {
        anAndroidUser.quits();        
        super.tearDown();
    }

    private String getString(int id){
        return anAndroidUser.getActivity().getString(id);
    }

    public void testThatTheHomePageShowsAnAppropriateWelcomingMessage(){
        anAndroidUser.looksAtThisTextView(R.id.welcoming_message)
                     .andItShouldContainThisText(getString(R.string.welcoming_message));
    } 

Notes :

  • It is important to have the right package name in the super call in the constructor
  • The test shows low levels concerns. Ideally, your scenario would be written in a DSL that is closer to the business language. Take a look at the Page pattern used in Selenium testing for more info
  • Since it is impossible at this moment to use jUnit 4 and its annotations while running test on Android, your test methods must unfortunately start with the word test.
  • For those with less than ideal development machine, using a real device instead of the emulator is a wise choice to have acceptable performances while running system tests.

Advantages over using InstrumentationTestCase

Using Loquacious, you can write scenarios that span over as many activities as you wish. The syntax is written form the standpoint of the activities that the user will do with your software

Advantages over using Robotium

Test are written using a fluent interface, meaning that the steps of a scenario can be read like a regular sentence. Scenarios implemented from the standpoint of the user will make it easier to integrate with Cucumber and the likes.

Powered by Google Project Hosting