The telemetry test harness is a set of classes and functions that allow rapid test development for testing the telemetry client within Firefox. It is build on top of Marionette for performing end to end tests and allowing the capturing and validation of ping data sent from Firefox's telemetry engine. It makes use of Marionette and Firefox Puppeteer to interact with the browser to generate the desired data in the pings. This helps to catch regressions in the behavior of the telemetry client.
Running The Telemetry Tests
Types of Telemetry Tests
The client tests use Marionette to perform different actions within Firefox and spin up an HTTP server that will be used to capture the pings as they are sent from the client. Once pings are captured, the developer can do a number of different types of assertions and validations against the data.
The unit tests ensure that the different components of the Telemetry Test Harness are in working order.
Writing Telemetry Tests
Telemetry tests support test cases written in Python, using Python's unittest framework, similar to Firefox UI Tests. Tests are written as a subclass of the TelemetryTestCase. More test case classes may be created to support additional groups of functionality. For information on the structure and form of writing these tests, the Firefox UI Test MDN Article is very helpful.
Certain testing preferences affect the outcome of the tests in telemetry. These prefs need to be enforced and to trigger a restart of Firefox. To do that we need to use the Marionette API to enforce the prefs on the Gecko level.
If you would like to make modifications to the ping server (i.e. add another path for pings, etc.), you can register a new handler to the ping server which is a modified HTTP server from the Web Platform Test Server (wptserve) package. Please do not create a new web server.
# self.httpd is the variable for the web server. ping_route = [("POST", re.compile('/pings'), self.pings)] self.httpd.routes.extend(ping_route)