Adding Tests

How to add your own tests for Thunderbird.

Generally, tests live near the code they are testing, however Mozmill tests live in two particular directories.

This document doesn't cover actually writing tests, for that see this page for Mochitests:

And also these pages on MDN:

(Just note that the MDN pages are Firefox-centric and include some ancient ideas and practices.)

XPCShell & Mochitest

Tests should be added to a directory near the code they are located. For example, code in mail/components/extensions is tested by tests in mail/components/extensions/test. Inside the test directory is a subdirectory named after the type of test: browser for Mozmill tests (as in Firefox terms they are "browser-chrome" Mozmill tests), and xpcshell or unit for XPCShell tests.

A new directory needs a test manifest:

XPCShell test manifest (xpcshell.ini)

The default section isn't even necessary here, but you probably want to add a head.js file if you're going to have more than one test.


Mochitest manifest (browser.ini)

Mochitest needs some prefs set, or automated testing will fail.

prefs =
subsuite = thunderbird

For tests that need to load messages in the UI, add this pref:


For calendar mochitests, also add this pref so the tests don't fail on beta or ESR where they're packaged differently:


Linking to manifests

The next thing you need to do is tell mach about your new test manifest. In the nearest file, add these lines as appropriate:


It's not really ideal to be adding new Mozmill tests. The platform is obsolete and now that Mochitest runs on Thunderbird it's preferred over Mozmill. But sometimes, you've gotta do what you've gotta do.

All Mozmill tests live in mail/test/mozmill, except for calendar tests, which live in calendar/test/mozmill. The test files themselves general live one directory deeper than that and are named test-something.js (or testSomething.js). To add a new test, put it in one of the existing directories, or if you must, create a new directory and add its name to the file mozmilltests.list.

If you add a calendar Mozmill test, you'll need to build again before you can use it.