Skip to:
Content
Pages
Categories
Search
Top
Bottom

Automated Testing

BuddyPress 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 BuddyPress plugins, or if you are contributing to BuddyPress core, please consider using (and writing!) these tests.

The BuddyPress 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/BuddyPress development environment.
  2. Check out the BuddyPress Subversion repository. At the moment, we do not plan to distribute the test suite with the .zip download of BuddyPress. To use the BuddyPress test suite, you’ll need to check out BuddyPress trunk from buddypress.trac.wordpress.org.

    $ svn co http://buddypress.svn.wordpress.org/trunk buddypress

    Please note that your checkout of BuddyPress trunk must be at or beyond revision 6908.

  3. Define WP_TESTS_DIR in your bash profile (optional). The test suite requires an environment variable WP_TESTS_DIR that defines the location of your checkout of the WordPress tests. While it’s possible to define the environment variable each time you run the tests, ie, WP_TESTS_DIR=~/sites/tests/phpunit, 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_TESTS_DIR="/home/bgorges/sites/tests/phpunit"

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

Running the tests

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

$ phpunit