Notice: You are browsing the documentation for PrestaShop 9, which is currently in development.
You might want to read the documentation for the current version, PrestaShop 8. Read the current version of this page
You can execute the test suite with specific Composer command:
composer unit-tests
composer test-all
command.This is thoroughly explained in the Puppeteer tests Readme file.
When implementing a new feature it is much faster to run only your specific tests. You can run only one test class with phpunit. But you must provide the phpunit.xml configuration to get the test environment bootstrapped correctly.
vendor/bin/phpunit -c tests/Unit/phpunit.xml tests/Unit/PrestaShopBundle/Command/ConfigCommandTest.php
Or even just few test methods
vendor/bin/phpunit --debug -c tests/Unit/phpunit.xml tests/Unit/PrestaShopBundle/Command/ConfigCommandTest.php --filter testSet
--debug
without --filter
gives a nice list to filter with.To check if you covered everything in your test cases, it’s best to run the tests with phpunit coverage report.
First, get your environment up and running.
Then, install and enable Xdebug.
Finally, run your tests with coverage enabled:
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text -c tests/Unit/phpunit.xml tests/Unit/PrestaShopBundle/Command/ConfigCommandTest.php
You may use a Dockerized environment to run the project.
After that is up and running, you need to compile and enable Xdebug:
docker compose exec prestashop_container pecl install xdebug #prestashop_container is the container's name
docker compose exec prestashop_container docker-php-ext-enable xdebug #prestashop_container is the container's name
Then run your tests with coverage enabled:
docker compose exec -e XDEBUG_MODE=coverage prestashop_container vendor/bin/phpunit --coverage-text -c tests/Unit/phpunit.xml tests/Unit/PrestaShopBundle/Command/ConfigCommandTest.php
This will give you a nice report of how much of your code was covered by the tests, and you can extend your tests to get closer to a perfect score of 100%.