This is a fork of Nikolay Bachiyski's alternative WordPress testing framework. The fork makes testing plugins easier.
WordPress already has an automated testing suite. What you see here is an alternative testing framework, with the following goals:
- runs every test case in a clean WordPress install
- uses the default PHPUnit runner, instead of custom one
- doesn't encourage or support the usage of shared/prebuilt fixtures
It uses SQL transactions to clean up automatically after each test.
- Install PHPUnit http://phpunit.de
- Clone the project.
- Edit the config. USE A NEW DATABASE, BECAUSE ALL THE DATA INSIDE WILL BE DELETED.
$ phpunit TestAll # test plugins and all tests
$ phpunit TestPlugins # test just plugins activated in unittests-config.php
$ phpunit test_test.php
Writing Tests for Plugins
Plugin tests should be stored in a wp-tests directory inside the plugin's root directory. Each file should be prepended with "test_" so that the test suite can automatically discover each test case.
require the tests within your plugin.