A basic skeleton for writing test for WordPress Plugins/Themes.
Download or Clone this repo
. Copy the tests
folder and paste into
Your plugin directory (Ex. /wp-content/plugins/myplugin/)
Create a new database for test. (Ex. wpunittest)
Go to the tests folder and Edit wp-tests-config.php
file according to
your preference.
Install phpunit
If you are using ubuntu/Linux Mint, you can type sudo apt-get install phpunit
in your terminal to install phpunit.
Inside the tests
folder. Create your first test file. Make sure you prefix the file
name with test
. There is also an example file test-test.php
in the test folder.
Use your terminal and go to the test folder. Then type phpunit
.