Back to Top

Running Unit Tests in Magento2 using CLI command

Updated 8 May 2023

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

Start your headless eCommerce
now.
Find out More
. . .

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