LogoLogo
  • About Thunderbird
  • Contributing to Thunderbird
    • Getting Started Contributing
    • Setting Up A Build Environment
    • Building Thunderbird
      • Windows Build Prerequisites
      • Linux Build Prerequisites
      • macOS Build Prerequisites
      • Artifact Builds
    • Codebase Overview
      • Account Configuration
      • Address Book
      • Chat Core
        • Notifications
        • Message Styles
        • Keyboard shortcuts
        • Chat Core Protocols
        • Contacts
      • Mail Front-End
    • Tutorials and Examples
      • Hello World Example
      • Thunderbird Live Development Videos
    • Fixing a Bug
      • Bug Triaging 101
        • Bug Status Classicification
        • Bug Types
        • Garbage Collection
        • Narrow the Scope
      • Using Mercurial Bookmarks
      • Using Mercurial Queues
      • Lint and Format Code
      • Using ESLint to Format Javascript Code
      • Try Server
      • Landing a Patch
      • Care and Feeding of the Tree
    • Testing
      • Running Tests
      • Adding Tests
      • Writing Mochitest Tests
  • Planning
    • Roadmap
    • Android Roadmap
    • Supported Standards
  • Add-on Development
    • Introduction
    • What's new?
      • Manifest Version 3
    • A "Hello World" Extension Tutorial
      • Using WebExtension APIs
      • Using a Background Page
      • Using Content Scripts
    • A Guide to Extensions
      • Supported Manifest Keys
      • Supported UI Elements
      • Supported WebExtension APIs
      • Thunderbird's WebExtension API Documentation
      • Thunderbird WebExtension Examples
      • Introducing Experiments
    • A Guide to Themes
    • Developer Community
    • Documentation & Resources
      • Tips and Tricks
    • Add-on Update Guides
      • Update for Thunderbird 128
      • Update for Thunderbird 115
        • Adapt to Changes in Thunderbird 103-115
      • Update for Thunderbird 102
        • Adapt to Changes in Thunderbird 92-102
      • Update for Thunderbird 91
        • Adapt to Changes in Thunderbird 79-91
      • Update for Thunderbird 78
        • Adapt to Changes in Thunderbird 69-78
      • Update for Thunderbird 68
        • Adapt to Changes in Thunderbird 61-68
      • How to convert legacy extensions?
        • Convert wrapped WebExtensions to modern WebExtensions
        • Convert legacy WebExtensions to modern WebExtensions
        • Convert legacy overlay extension to legacy WebExtension
        • Convert legacy bootstrapped extension to legacy WebExtension
  • Releases
    • Thunderbird Channels
    • Release Cadence
    • Uplifting Fixes
    • Feature Flags
    • Tracking Fixes for Releases
    • Contributing to Release Notes
Powered by GitBook
On this page
  • XPCShell & Mochitest
  • XPCShell test manifest (xpcshell.toml)
  • Mochitest manifest (browser.toml)
  • Linking to manifests

Was this helpful?

Edit on GitHub
Export as PDF
  1. Contributing to Thunderbird
  2. Testing

Adding Tests

How to add your own tests for Thunderbird.

PreviousRunning TestsNextWriting Mochitest Tests

Last updated 26 days ago

Was this helpful?

Generally, tests live near the code they are testing, however some old tests are in a separate test directory.

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

And also these pages:

  • (archived MDN content)

(Just note that these 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 mochitests (as in Firefox terms they are "browser-chrome" mochitests), and xpcshell or unit for XPCShell tests.

A new directory needs a test manifest:

XPCShell test manifest (xpcshell.toml)

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.

xpcshell.toml
[default]
prefs = [
  "calendar.timezone.local=UTC",
]

["test_firstTest.js"]

The calendar preferences in line 3 is unnecessary outside of the calendar tests. Calendar tests always run in UTC.

Mochitest manifest (browser.toml)

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

browser.toml
[default]
prefs = [
  "calendar.timezone.local=UTC",
  "calendar.week.start=0",
  "mail.spotlight.firstRunDone=true",
  "mail.winsearch.firstRunDone=true",
  "mailnews.start_page.override_url=about:blank",
  "mailnews.start_page.url=about:blank",
]
subsuite = "thunderbird"

["browser_firstTest.js"]

The calendar preferences in lines 3-4 are unnecessary outside of the calendar tests. Calendar tests always run in UTC with the week starting on Sunday.

Linking to manifests

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.build
BROWSER_CHROME_MANIFESTS += [
    'test/browser/browser.toml',
]
XPCSHELL_TESTS_MANIFESTS += [
    'test/xpcshell/xpcshell.toml',
]
Writing Mochitest Tests
Writing xpcshell-based unit tests
Mochitest