diff --git a/contributing/code/tests.rst b/contributing/code/tests.rst index 6e14a9d412f..913c5419b71 100644 --- a/contributing/code/tests.rst +++ b/contributing/code/tests.rst @@ -3,54 +3,32 @@ Running Symfony Tests ===================== -Before submitting a :doc:`patch ` for inclusion, you need to run the -Symfony test suite to check that you have not broken anything. +The Symfony project uses a third-party service which automatically runs tests +for any submitted :doc:`patch `. If the new code breaks any test, +the pull request will show an error message with a link to the full error details. -PHPUnit -------- +In any case, it's a good practice to run tests locally before submitting a +:doc:`patch ` for inclusion, to check that you have not broken anything. -To run the Symfony test suite, `install PHPUnit`_ 4.2 (or later) first. +.. _phpunit: +.. _dependencies_optional: -Dependencies (optional) ------------------------ +Before Running the Tests +------------------------ -To run the entire test suite, including tests that depend on external -dependencies, Symfony needs to be able to autoload them. By default, they are -autoloaded from ``vendor/`` under the main root directory (see -``autoload.php.dist``). - -The test suite needs the following third-party libraries: - -* Doctrine -* Swift Mailer -* Twig -* Monolog - -To install them all, use `Composer`_: - -Step 1: :doc:`Install Composer globally ` - -Step 2: Install vendors. +To run the Symfony test suite, `install PHPUnit`_ 4.2 (or later) first. Then, +install the external dependencies used during the tests, such as Doctrine, Twig +and Monolog. To do so, :doc:`install Composer ` and execute +the following: .. code-block:: bash $ composer install -.. note:: - - Note that the script takes some time to finish. +.. _running: -After installation, you can update the vendors to their latest version with -the follow command: - -.. code-block:: bash - - $ composer update - -Running -------- - -First, update the vendors (see above). +Running the Tests +----------------- Then, run the test suite from the Symfony root directory with the following command: @@ -59,40 +37,17 @@ command: $ phpunit -The output should display ``OK``. If not, you need to figure out what's going on -and if the tests are broken because of your modifications. +The output should display ``OK``. If not, read the reported errors to figure out +what's going on and if the tests are broken because of the new code. .. tip:: - If you want to test a single component type its path after the ``phpunit`` - command, e.g.: + The entire Symfony suite can take up to several minutes to complete. If you + want to test a single component, type its path after the ``phpunit`` command, + e.g.: .. code-block:: bash $ phpunit src/Symfony/Component/Finder/ -.. tip:: - - Run the test suite before applying your modifications to check that they - run fine on your configuration. - -Code Coverage -------------- - -If you add a new feature, you also need to check the code coverage by using -the ``coverage-html`` option: - -.. code-block:: bash - - $ phpunit --coverage-html=cov/ - -Check the code coverage by opening the generated ``cov/index.html`` page in a -browser. - -.. tip:: - - The code coverage only works if you have Xdebug enabled and all - dependencies installed. - -.. _install PHPUnit: https://phpunit.de/manual/current/en/installation.html -.. _`Composer`: https://getcomposer.org/ +.. _`install PHPUnit`: https://phpunit.de/manual/current/en/installation.html