Marionette Python Tests

Marionette supports test cases written in Python, using Python's unittest framework.  Tests are written as a subclass of MarionetteTestCase, with individual tests belonging to instance methods that have a name starting with "test".  Additionally, you can provide setUp and tearDown instance methods to execute code before and/or after tests in a particular test class have run, but remember to call setUp/tearDown methods of MarionetteTestCase in your provided function, since MarionetteTestCase handles setup/cleanup between test cases.

This test structure is illustrated here:

from marionette_test import MarionetteTestCase
class TestSomething(MarionetteTestCase):
    def setUp(self):
        # code to execute before any tests are run
        MarionetteTestCase.setUp(self)
    def test_foo(self):
        # run test for 'foo'
    def test_bar(self):
        # run test for 'bar'
    def tearDown(self):  
        # code to execute after all tests are run
        MarionetteTestCase.tearDown(self)

Test Assertions

Methods which make test assertions are provided courtesy of unittest; for example:

from marionette_test import MarionetteTestCase
class TestSomething(MarionetteTestCase):
    def test_foo(self):
        self.assertEqual(9, 3 * 3, '3 x 3 should be 9')
        self.assertTrue(type(2) == int, '2 should be an integer')

Emulator Integrated Tests

The test runner has the ability to control and communicate with multiple emulators. Please see the Emulator Integrated Tests subpage for more details!

The API

MarionetteTestCase - A subclass of unittest.TestCase, and is used as a base class for all tests run

Marionette object - This object sends commands to a marionette instance

Emulator object - This is the emulator object, which you have access to if you launch an emulator with the test runner

Document Tags and Contributors

 Contributors to this page: fscholz, Sheppy, mdas, jgriffin
 Last updated by: fscholz,