3 _Marionette_ is the codename of a [remote protocol] built in to
4 Firefox as well as the name of a functional test framework for
5 automating user interface tests.
7 The in-tree test framework supports tests written in Python, using
8 Python’s [unittest] library. Test cases are written as a subclass
9 of `MarionetteTestCase`, with child tests belonging to instance
10 methods that have a name starting with `test_`.
12 You can additionally define [`setUp`] and [`tearDown`] instance
13 methods to execute code before and after child tests, and
14 [`setUpClass`]/[`tearDownClass`] for the parent test. When you use
15 these, it is important to remember calling the `MarionetteTestCase`
16 superclass’ own [`setUp`]/[`tearDown`] methods since they handle
17 setup/cleanup of the session.
19 The test structure is illustrated here:
22 from marionette_harness import MarionetteTestCase
24 class TestSomething(MarionetteTestCase):
26 # code to execute before any tests are run
27 MarionetteTestCase.setUp(self)
36 # code to execute after all tests are run
37 MarionetteTestCase.tearDown(self)
40 [remote protocol]: Protocol.md
41 [unittest]: https://docs.python.org/3/library/unittest.html
42 [`setUp`]: https://docs.python.org/3/library/unittest.html#unittest.TestCase.setUp
43 [`setUpClass`]: https://docs.python.org/3/library/unittest.html#unittest.TestCase.setUpClass
44 [`tearDown`]: https://docs.python.org/3/library/unittest.html#unittest.TestCase.tearDown
45 [`tearDownClass`]: https://docs.python.org/3/library/unittest.html#unittest.TestCase.tearDownClass
49 Assertions are provided courtesy of [unittest]. For example:
52 from marionette_harness import MarionetteTestCase
54 class TestSomething(MarionetteTestCase):
56 self.assertEqual(9, 3 * 3, '3 x 3 should be 9')
57 self.assertTrue(type(2) == int, '2 should be an integer')
62 The full API documentation is found [here], but the key objects are:
64 * `MarionetteTestCase`: a subclass for `unittest.TestCase`
65 used as a base class for all tests to run.
67 * {class}`Marionette <marionette_driver.marionette.Marionette>`: client that speaks to Firefox
69 [here]: /python/marionette_driver.rst