Skip to content
- Karen NA Gupta. Unit Testing WordPress Plugins with PHPUnit. wpmudev, 2017.
- Camden Segal. Unit Testing Your Plugins. webdevstudios, 2014.
- David Hayes. How to Start Unit Testing WordPress Plugins. wpshout, 2018.
- Collins Agbonghama. An Introduction to Automated Testing of WordPress Plugins with PHPUnit. smashing magazine, 2017.
- Good introductory article, includes directions on writing a small plugin, creating tests, and using phpunit.
- Pippin Williamson. Unit Tests for WordPress Plugins Series. 2014-2015.
- 2. Setting Up Our Testing Suite – Defines “testing suite”, installing PHPUnit and WP-CLI, how to use WP-CLI to setup unit tests, defines “tests” and “assertions”.
- 3. Writing Tests – Why/how to segment tests across multiple files, demonstrates writing several different tests.
- 4. The Factory – Discusses using WP_UnitTest_Factory to create sample data. Particularly demonstrates how to create a sample post / many sample posts / a sample user, creating a custom factory class.
- Carl Alexander. Introduction to WordPress Unit Testing. 2015.
- Explains the why of unit testing, discusses requirements including OS, PHP versions, Composer, PHPUnit, and WP-CLI. It also discusses PHP-Mock, test doubles, using a prefix helper function, and assertions.
- Carl Alexander. How Do You Start Unit Testing Existing WordPress Code?
- Zack Grossbart. Writing Unit Tests for WordPress Plugins. smashing magazine, 2012.
- WP Safe Updates – In cases where a host doesn’t offer a staging environment, WP Safe Updates create a sandbox environment so that plugins can be tested before upgrading.
- FakerPress – Creates test data for WP install.