Skip to:
Content
Pages
Categories
Search
Top
Bottom

Automated Testing

Codex HomeDeveloper Resources → Automated Testing

bbPress contains a suite of automated tests. These tests are designed to prevent the accidental introduction – or reintroduction – of bugs. If you are a developer of bbPress plugins, or if you are contributing to bbPress core, please consider using (and writing!) these tests.

The bbPress test system is based on, and uses, the WordPress suite. Before getting started, you are encouraged to read more about how WordPress tests work.

Installation

  1. Set up the WordPress test suite. You’ll need to install PHPUnit, check out the WordPress core test repository, create a blank MySQL database, and set up your wp-tests-config.php file. Follow the instructions in the WordPress contributor handbook to get set up. The WordPress test suite can be located anywhere on your development machine, though it’s recommended that you place it somewhere outside your normal WordPress/bbPress development environment.
  2. Check out the bbPress Subversion repository. At the moment, we do not plan to distribute the test suite with the .zip download of bbPress. To use the bbPress test suite, you’ll need to check out bbPress trunk from bbpress.trac.wordpress.org.

    $ svn co https://bbpress.svn.wordpress.org/trunk bbpress

    Please note that your checkout of bbPress trunk must be at or beyond revision 5264.

  3. Define WP_DEVELOP_DIR in your bash profile (optional). The test suite requires an environment variable WP_DEVELOP_DIR that defines the location of your checkout of the WordPress Development Repo (instructions). While it’s possible to define the environment variable each time you run the tests, ie, WP_DEVELOP_DIR=~/sites/wordpress-develop, you’ll probably find it useful to set the variable permanently in your bash profile.On OS X or Linux, add the following line to ~/.bashrc:

    export WP_DEVELOP_DIR="/home/username/sites/wordpress-develop"

    (changing the path to wherever you installed the WP tests in step 1). To apply these changes,

    source ~/.bashrc

    .
    On Windows, add the following line to your PowerShell ~/.profile:

    $ENV:WP_DEVELOP_DIR="C:\xampp\htdocs\wordpress-develop\"

    (changing the path to wherever you installed the WP tests in step 1). To apply these changes,

    .profile

    .

Running the tests

Navigate to the bbPress plugin folder, and type phpunit. (If you didn’t add WP_DEVELOP_DIR to your profile in step 3 above, you’ll need to define that environment variable inline.) Then:

$ phpunit

Skip to toolbar