Running Unit Tests in Magento2 using CLI command
Running all unit tests
- Navigate to your Magento root directory.
- Run the below command, where
coption specifies the path to thephpunitconfiguration file
./vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist
Running only a subset of the unit tests
- For running unit tests only for a single module use the below command.
./vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist app/code/Example/Module/Test/Unit
- You need to specify your module directory as shown in the above code snippet.
- After that, the
phpunitwill scan the directory for files ending withTest.phpand try to execute them.
You can visit the following blog for creating the unit test.
https://webkul.com/blog/php-unit-test-in-magento-open-source/: Running Unit Tests in Magento2 using CLI command
Categories:
Uncategorized
View Comments
Comment or Ask a Question
Quick Links