/home/rwood

  • About

WebAPI Emulator Tests: Mochitest vs Marionette

Posted by rwood on October 16, 2012
Posted in: Uncategorized. Tagged: automation, b2g, firefoxos, marionette, mochitest, webapi.

Development of an extensive test suite to verify the functionality of the first group of Firefox OS WebAPIs is underway. Ultimately the test suite will run on the B2G device emulator on a per-check-in basis.

To develop a WebAPI test which will run on the B2G device emulator, which automation framework is best suited for the task: Mochitest or Marionette? This blog post will help answer that question, and provide some useful emulator tips.

The Mochitest automation framework has access to gecko and the WebAPIs but cannot access the lower-level emulated ‘hardware’ features and commands that are offered in the B2G emulator. The Marionette automation framework can access both the WebAPIs and the emulated ‘hardware’ and associated emulator commands. Therefore, if the WebAPI test under development requires direct access to the emulated hardware support and special emulator functions, then Marionette should be used; otherwise Mochitest is sufficient for the task.

For example, if you are developing a new WebAPI test for the ContactsAPI, Mochitest is the best choice as no special emulated hardware access or functions is required to test Contacts. However, if you are developing a WebAPI test for the WebTelephony API, Marionette is the automation framework of choice because the B2G device emulator has special commands that allow the partial-simulation of phone calls.

The B2G device emulator offers console commands that can help emulate specific hardware features, and therefore be used to verify some of the WebAPIs. To see a list of commands (or to try out some of them yourself) start-up the B2G device emulator, then open a terminal window and connect to the emulator’s android console via telnet:

$ telnet localhost 5554

Where ’5554′ is the default emulator port (displayed on the emulator window title). Once connected to the emulator’s android console, simply type ‘help’ to see a list of available commands. As an example, to use the emulator to simulate an incoming phone call, issue the following command in the android emulator console:

gsm call 5551112222

Where ’5551112222′ is the phone number of the simulated remote mobile from which the incoming call is originated. Once the above command is issued, notice that the emulator gui (gaia) indicates that there is an incoming call from the specified number. The simulated call can then be answered or rejected using more emulator console commands (or via the gaia interface itself).

To send a console command to the emulator from within a WebAPI test, Marionette provides the ‘runEmulatorCmd’ function. For example, to simulate an incoming call on the emulator use the following js code in your WebAPI test:

let inNumber = “5551112222″;
runEmulatorCmd(“gsm call ” + inNumber);

As an optional argument to ‘runEmulatorCmd’, a callback function can be provided which will be invoked after the emulator processes the command, and the emulator console output will be provided. For example:

runEmulatorCmd(“gsm list”, function(result) {
log(“Current call list: ” + result);
});

The ‘gsm list’ command asks the emulator to output a list of currently simulated phone calls and their status. In the above example the resulting console output of the command (list of simulated calls, or just ‘ok’ if no calls exist) is provided to the callback function. For more information see Marionette JavaScript Tests in MDN.

Additional information about the Automation Development team’s efforts to help with WebAPI test development can be found on our team’s projects wiki. If you are interested in contributing please contact me or find us in the #automation room on IRC.

(Thanks JGriffin and MDas for answering my various questions on these subjects.)

MozCampEU 2012!

Posted by rwood on September 13, 2012
Posted in: Uncategorized. Tagged: automated test development, automation, b2g, boot2gecko, firefoxos, mozcamp, mozilla project. Leave a Comment

Last weekend (Sept.7-9th, 2012) I had the privilege of attending my very first Mozilla MozCamp: MozCampEU 2012 in Warsaw, Poland! The theme for this particular MozCamp was “Mobilize Mozilla”, and as one speaker pointed out, the theme was appropriate in two ways.  Firstly, mobilizing hundreds of like-minded Mozillians from 30 countries, into one amazing location in the heart of Europe.  Secondly, one of the major topics of discussion and work at the event was Mozilla’s Boot2Gecko project, also known as the FireFox OS!

At the conference I attended several fantastic sessions on a wide range of B2G related topics.  A couple of my favourites were “How to Create New Web APIs” by fellow Mozillians Gregor Wagner and Julian Viereck, and “B2G and Apps Security” by Lucas Adamski.

As well as attending many excellent sessions, I also co-hosted an automated test development session with Henrik Skupin, one of my awesome Mozilla automation teammates.  Our session, ‘Make Sure Your Code Works‘, served as an introduction to B2G WebAPI automated test development, and had participants hacking automated tests in javascript (to be run on the B2G device emulator).  I would like to thank everyone who attended our session, and thank you to those of you whom also submitted code afterwards.  If you are interested in learning more about B2G automated test development, or in becoming a contributor to the automation efforts on this exciting project, feel free to contact me or join our #automation channel on the Mozilla IRC.

In closing, MozCampEU 2012 was absolutely fantastic, and a very worthwhile experience. I also must mention how I met many incredible Mozillians in Warsaw!!  It was a pleasure to meet such great friends who have an amazing dedication and passion for the Mozilla project.  Keep in touch and best regards!

Posts navigation

  • Recent Posts

    • WebAPI Emulator Tests: Mochitest vs Marionette
    • MozCampEU 2012!
  • Twitter Updates

    Error: Twitter did not respond. Please wait a few minutes and refresh this page.

  • Top Posts & Pages

    • WebAPI Emulator Tests: Mochitest vs Marionette
  • archives

    • October 2012
    • September 2012
  • Tags

    automated test development automation b2g boot2gecko firefoxos marionette mochitest mozcamp mozilla project webapi
  • Enter your email address to follow this blog and receive notifications of new posts by email.

    Join 1 other follower

  • Meta

    • Register
    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.com
Blog at WordPress.com. Theme: Parament by Automattic.
Follow

Get every new post delivered to your Inbox.

Powered by WordPress.com