# Unit Testing
The Pressbooks unit testing framework was built (then slightly tweaked) using WP-CLI (opens new window). The tests run automatically on commit via GitHub Actions (opens new window), with more in-depth reporting via Codecov (opens new window).
To run the tests locally, do:
cd /path/to/wordpress/wp-content/plugins/pressbooks bash bin/install-wp-tests.sh wordpress_test DBUSER DBPASS localhost latest phpunit
/path/towith your path.
wordpress_testis the name of a new test database (all data will be deleted!)
DBUSERis your MySQL user name
DBPASSis your MySQL user password
localhostis your MySQL host
latestis the WordPress version; could also be
- Make sure PHPUnit (opens new window) is installed
The bash script installs a copy of WordPress and the WordPress unit testing tools in
/tmp. It then creates a new tests database to be used while running tests. The bash script can be run multiple times without errors, but it will not overwrite previously existing files.
Tests are in
Tests cover the code in