canmove, Confirmed users, Bureaucrats and Sysops emeriti
3,627
edits
(Add section with link to the list of current problems for xpcshell tests.) |
(Add some basic guidelines and restructure the page a bit.) |
||
Line 7: | Line 7: | ||
MailNews has a growing set of xpcshell tests. Developers and contributors should consider adding tests within MailNews where possible. | MailNews has a growing set of xpcshell tests. Developers and contributors should consider adding tests within MailNews where possible. | ||
== xpcshell tests within MailNews == | xpcshell tests can be run in a variety of different ways, the [http://developer.mozilla.org/en/docs/Writing_xpcshell-based_unit_tests devmo wiki page] describes these best. | ||
== xpcshell test reporting == | |||
These currently run on the [http://tinderbox.mozilla.org/SeaMonkey/ SeaMonkey tinderboxes], and report as TUnit. Thunderbird hopes to pick running of these up soon ({{bug|422817}}). | |||
== Developing xpcshell tests within MailNews == | |||
When developing new tests it is useful to look at the [http://developer.mozilla.org/en/docs/Writing_xpcshell-based_unit_tests devmo documentation for writing xpcshell-based unit tests] | |||
[http://mxr.mozilla.org/seamonkey/find?text=&kind=text&string=%2Fmailnews%2F.*test_.* This list links the existing tests] that are currently within Thunderbird. | |||
The review policy for tests is [[MailNews:Automated_Testing#Rules_and_Review_Policy|located here]]. | |||
=== MailNews xpcshell test facilities === | |||
Once {{bug|432812}} is checked in, each existing directory where tests are run will have head_*.js and tail_*.js files that will provide the following by importing core scripts: | |||
* A global variable "profileDir" containing an nsIFile variable with the profile directory to use for the xpcshell tests. | |||
* A nsIDirectoryService that points at the profileDir and provides the necessary facilities to use profile-related directories, e.g. NS_GetSystemDirectory("MailD", ...). | |||
* Automatic cleanup of the profile directory | |||
** This is important so that the results of one test do not affect the results of another and the redundant data gets deleted (for developers running tests). | |||
== Guidelines for new tests == | |||
These guidelines are intended to provide some level of consistency across the MailNews tests. | |||
=== New Directories for tests === | |||
* | * New directories should be created as test/unit under whichever directory they apply, e.g. tests directly relating to the address book go into mailnews/addrbook/test/unit. | ||
* All new directories should have a head_*.js and a tail_*.js file, these should import some of the core mailnews scripts. | |||
** ''These changes haven't been checked in yet, see {{bug|432812}}'' | |||
* | |||
* | |||
** | |||
== | === New Tests === | ||
* The test name should be relevant to the class/action the bug is testing, or the bug number of the bug it is checking that it fixes. | |||
* Where the profile directory is required, use profileDir that is automatically created in [http://mxr.mozilla.org/seamonkey/source/mailnews/test/resources/mailDirService.js mailDirService.js] | |||
== Coming soon == | == Coming soon == |