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 these MDN pages:
(Just note that they're Firefox-centric and include some ancient ideas and practices.)
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
unit for XPCShell tests.
A new directory needs a test manifest:
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 needs some prefs set, or automated testing will fail.
browser.ini[default]prefs =ldap_2.servers.osx.description=ldap_2.servers.osx.dirType=-1ldap_2.servers.osx.uri=mail.provider.suppress_dialog_on_startup=truemail.spotlight.firstRunDone=truemail.winsearch.firstRunDone=truemailnews.start_page.override_url=about:blankmailnews.start_page.url=about:blanksubsuite = thunderbird[browser_firstTest.js]
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:
The next thing you need to do is tell mach about your new test manifest. In the nearest
moz.build file, add these lines as appropriate:
moz.buildBROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini',]XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell/xpcshell.ini',]
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
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