MailNews:Xpcshell tests: Difference between revisions
(Add some basic guidelines and restructure the page a bit.) |
(→MailNews xpcshell test facilities: Bug 432812 has now been checked in) |
||
Line 23: | Line 23: | ||
=== MailNews xpcshell test facilities === | === MailNews xpcshell test facilities === | ||
Each existing unit test directory has head_*.js and tail_*.js files that 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 global variable "profileDir" containing an nsIFile variable with the profile directory to use for the xpcshell tests. |
Revision as of 12:39, 14 May 2008
<< Back to MailNews:Automated Testing
The xpcshell unit tests are probably the easiest test to write, requiring no UI and being written in javascript. They are very useful for testing interfaces and back-end functionality.
MailNews has a growing set of xpcshell tests. Developers and contributors should consider adding tests within MailNews where possible.
xpcshell tests can be run in a variety of different ways, the devmo wiki page describes these best.
xpcshell test reporting
These currently run on the 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 devmo documentation for writing xpcshell-based unit tests
This list links the existing tests that are currently within Thunderbird.
The review policy for tests is located here.
MailNews xpcshell test facilities
Each existing unit test directory has head_*.js and tail_*.js files that 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 mailDirService.js
Coming soon
- bug 421050 Import tests for mailnews/import
- Will fix some aspects of creating local folders, actually allowing testing of these to be incorporated in xpcshell tests.
- First version of tests for Mail.app import testing.
- bug 413077 Fake server testing scheme for mailnews
- First version implements basic news server.
Problems running core xpcshell tests on MailNews
See MailNews:Automated_Testing#xpcshell_tests for the list of current problems.