Your Search Results

    MailNews xpcshell-tests

    This article is in need of a technical review.

    This page is not complete.

    MailNews xpcshell-tests are written and run in the same manner as the core xpcshell-tests. This page describes additional resources and facilities that MailNews has developed to support the xpcshell-tests; see the core xpcshell-tests page for more information on how to develop these.

    To run all xpcshell-test, run the following command in the source directory

    ./mozilla/mach xpcshell-test

    To run a single xpcshell test use (e.g.)

    ./mozilla/mach xpcshell-test mailnews/news/test/unit/test_server.js

    To run all xpcshell tests in a given directory, use (e.g.)

    ./mozilla/mach xpcshell-test mailnews/news

    For a single test or directory, if it's inside comm-central/mozilla/, then the path should be relative to comm-central/mozilla/, e.g.

    ./mozilla/mach xpcshell-test toolkit/components/passwrdmgr

    Review Requirements for new tests

    See MailNews Review Requirements.

    Memory Leaks

    When running the xpcshell-tests or check-one commands, if the test is successful and there are no reference count leaks, it will output:

    TEST-PASS | /Users/moztest/comm/main/tb/mozilla/_tests/xpcshell/test_mailnewsbase/unit/test_nsIMsgFolderListener.js | test passed

    If the test is successful, and there are reference count leaks, it will output something similar to:

    TEST-PASS | /Users/moztest/comm/main/tb/mozilla/_tests/xpcshell/test_mailnewsbase/unit/test_nsIMsgFolderListenerLocal.js | test passed
    == BloatView: ALL (cumulative) LEAK STATISTICS
                                                  Per-Inst   Leaked    Total      Rem      Mean       StdDev     Total      Rem      Mean       StdDev
       0 TOTAL                                          32      300    14949        6 (  155.82 +/-   189.73)    51641        6 (  148.25 +/-   229.91)
      28 morkObject                                     44      132      481        3 (   54.62 +/-    15.38)     1362        3 (   76.49 +/-    20.87)
      29 morkRowObject                                  56      168       97        3 (   17.40 +/-     4.96)      127        3 (   17.05 +/-     5.46)
    nsTraceRefcntImpl::DumpStatistics: 199 entries

    There are some mailnews tests which are currently known to leak, these are covered by the tracking bug bug 498147 and bug 438922. The general policy is that new tests shouldn't leak, unless covered by existing bugs. If new tests really need to land with leaks, then they must have bugs covering the leak.

    Test Startup and Profile Details

    All MailNews xpcshell-test directories have a head_*.js file that imports mailDirService.js. This file:

    • Will remove any existing files in the directory <objdir>/mozilla/_tests/mailtest.
    • Will set up an nsIDirectoryServiceProvider which will register <objdir>/mozilla/_tests/mailtest as the profile directory to use for each xpcshell-tests.
    • Provides a gProfileDir global variable that contains a nsIFile set up to point at <objdir>/mozilla/_tests/mailtest.

    Test Shutdown

    All MailNews xpcshell-tests directories should have a tail_*.js file that imports mailShutdown.js. This is done so that mailnews is shutdown correctly at the end of the unit tests which in turn ensures representative leak logs. The shutdown sequence is as follows:

    1. Do a cycle collection to clean up any js objects that are no longer required.
    2. Post the following shutdown notifications via the observer service:
      1. quit-application
      2. profile-change-net-teardown
      3. profile-change-teardown
      4. profile-before-change
    3. Unregisters the profile directory provider.

    Helper Resources

    Fake Servers

    The MailNews xpcshell-tests have available a selection of fake servers that are used to simulate IMAP, POP3, NNTP and SMTP servers. More information is available here.

    General Helpers

    There are a variety of helper functions and objects in the files within the directory. These give facilities such as:

    To load these into xpcshell-tests use the command:



    Document Tags and Contributors

    Contributors to this page: Sheppy, Standard8, Archaeopteryx, jenzed, avih, tessarakt4
    Last updated by: Archaeopteryx,