Unit testing

Unit tests are designed to test individual class methods in isolation, asserting all possible combinations and taking care of the smallest testable part of an application. Magento uses the PHPUnit testing framework for its unit tests. Being highly focused, unit tests make it easy to identify the root cause of issues if a certain test fails.

We can specifically trigger the unit tests from the root of the Magento installation by using the following command:

php bin/magento dev:tests:run unit

Once triggered, Magento will run the execute command in the vendor/magento/module-developer/Console/Command/DevTestsRunCommand.php file. Since the unit type is mapped to several commands, what will happen internally is that Magento will change the ...

Get Magento 2 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.