Writing Tests with Marionette

Marionette itself is a remote driver, but we have a test runner integrated with our python marionette client that's designed with Marionette in mind. This test runner can run tests according to environment (b2g on a phone, b2g on emulator, browser, etc.), and can start and control multiple B2G emulators, enabling you to synthesize events like power level changes, and can coordinate between them. For these kinds of tests, you'll need to write Marionette Python tests.

Marionette itself has simpletest-like features to it that will let you run tests within the JS runtime, and will return you the results of the test. Our client uses this capability for the Marionette JavaScript tests, self-contained pure JavaScript tests that can run in either chrome or content.

Types of Tests Supported

The test runner supports Marionette Python tests, which are similar to Selenium tests, and Marionette JavaScript WebAPI tests, which are similar to mochitest-browser-chrome tests.

Whereas pure JavaScript tests limit you to the chrome and content process of the test machine, Marionette Python tests have the added benefit of allowing you to do actions outside of the test space. For example, if you're running Boot2Gecko in two emulators and you'd like to send an SMS message to one from the other, then you can tell Marionette to:

 1 - Check number of messages in emulator A by using webAPI calls in content space
 2 - In emulator B, use content webAPI calls to send a text to emulator A.
 3 - Check the number of messages in emulator A, using webAPI in content again and assert that a new SMS has indeed arrived.

Since we're communicating remotely, we can coordinate actions and change state outside of the system under test.

These tests allow you to operate within the running environment, but also give you freedom to do operations elsewhere

More information

Document Tags and Contributors

Last updated by: fscholz,