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
  • Code integrity tests
  • XSS unsafe output test

JSHint, a JavaScript code quality tool, is used for JavaScript static code analysis. For PHP code standard verification, the elements of PHP_CodeSniffer libraries are used. PHP_CodeSniffer tokenizes PHP, JavaScript, and CSS files and detects violations of a defined set of coding standards.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.228.35