wp scaffold plugin-tests
Generates files needed for running PHPUnit tests in a plugin.
Generated Files
phpunit.xml.dist– PHPUnit configuration.circleci/config.yml– CircleCI configuration (or other CI via--ci)bin/install-wp-tests.sh– WordPress test suite and database setuptests/bootstrap.php– Makes current plugin active when running teststests/test-sample.php– Sample file with actual tests.phpcs.xml.dist– PHP_CodeSniffer rules
Learn more from the plugin unit tests documentation.
Environment
The tests/bootstrap.php file looks for the WP_TESTS_DIR environment variable.
Synopsis
wp scaffold plugin-tests [<plugin>] [--dir=<dirname>] [--ci=<provider>] [--force]
Options
[
The name of the plugin to generate test files for.
[–dir=
Generate test files for a non-standard plugin path. If no plugin slug is specified, the directory name is used.
[–ci=
Choose a configuration file for a continuous integration provider.
- default: circle
- options: circle, gitlab, bitbucket, github
[–force]
Overwrite files that already exist.
Examples
# Generate unit test files for plugin 'sample-plugin'
$ wp scaffold plugin-tests sample-plugin
Success: Created test files.