Webkul
Services
Technologies Bagisto QloApps
iOS Android SAP BigCommerce Wix
Trusted by
Samsung Intel Toyota Walmart Disney Nokia Nestlé Decathlon
See all customers
Back to Top
DOC

Running Unit Tests in Magento2 using CLI command

Running all unit tests

  • Navigate to your Magento root directory.
  • Run the below command, where c option specifies the path to the phpunit configuration 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 phpunit will scan the directory for files ending with Test.php and 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
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home