WordPress.org

Codex

User:Hakre/WP Unit-Tests

Contents

WordPress Unit Testing

Back to my Page | Codex Page: Automated Testing

Testrun

I just made a testrun so see if I can get it working. Getting the tests to run revealed the following TODO:

  1. Better Cross-Plattform Support for includes. (solved #11867)
  2. Support for Non-Getopt. (solved #11867)
  3. Fail: die() stops unit-tests (solved #11892)
  4. Fail: Colors are not supported under windows (patch #12277)
  5. Fail: Tests do warnings on unset variables which are normally set in webserver environments (patch #12283)
  6. Where are the automatic runs? (pending)

Next to this things left to do, I offer some documentation so that you can get a faster start right away.

Devlog

  1. 2010-01-11 Ticket: #11867; Patch: 11867-interoperability.patch; Post: Cross-Plattform interoperability of the Test Suite;

Documentation

Before you can run the WordPress Testing Framework you need to match the requirements.

Requirements

Mainly the tests require PHPUnit. But PHPUnit itself is based on other components, so these are:

  1. Pear
  2. XDebug
  3. PHPUnit

Pear Package Manager

Install with go-pear if you do not have it already. After installation spend it an update:

pear upgrade PEAR

This is always a good idea for PEAR and the PHPUnit installation would otherwise reveal a lot of warning and problems.

XDebug

XDebug installation instructions, would be either by donwloading a binary or by # pecl install xdebug (some systems only). Must be configured in PHP.ini afterwards.

PHPUnit

PHPUnit Installation as easy as: pear channel-discover pear.phpunit.de pear channel-discover components.ez.no pear channel-discover pear.symfony-project.com pear install –alldeps phpunit/PHPUnit

Installing the testing framework

After fulfilling the requirements, you can obtain the testing framework as described here. Basically all you need is to checkout the tests from SVN and to create a database and a wp-config.php. Then you're ready to run tests.

2009 Summary

There is a set of unit-tests for WordPress and WordPress MU. Those tests are based on PHPUnit. The Project is lead by Peter Westwood (Westi), one of the WordPress Lead Develeopers.

A full metric can be created by combining codesniffer and unittests output: http://github.com/beberlei/puma/tree/master next to this, validation of HTML output could be measured as well (not covered by that link). in case of untestable code, runkit might come to the help (http://www.whitewashing.de/blog/articles/115).

Links