Static testing

Static tests do not really run the code; they analyze it. They are used to verify that the code conforms to certain coding standards, such as PSR-1. We can find them under the dev/tests/static directory.

To specifically trigger static tests only, we can execute the following command on the console:

php bin/magento dev:tests:run static

When executed, Magento internally changes the directory to dev/tests/static and executes a command that is similar to the following one:

php /Users/branko/www/magento2/./vendor/phpunit/phpunit/phpunit

The static directory has its own phpunit.xml.dist file. Looking at its testsuite definition, you will see the following four test suites defined:

  • JavaScript static code analysis
  • PHP coding standard verification ...

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.