Skip to content

Commit d17a20f

Browse files
committed
Further tweaks to the PHPUnit configuration description
1 parent 61cdfcc commit d17a20f

File tree

1 file changed

+58
-29
lines changed

1 file changed

+58
-29
lines changed

book/testing.rst

Lines changed: 58 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ it has its own excellent `documentation`_.
2121
needed to test the Symfony core code itself.
2222

2323
Each test - whether it's a unit test or a functional test - is a PHP class
24-
that should live in the `Tests/` subdirectory of your bundles. If you follow
24+
that should live in the ``Tests/`` subdirectory of your bundles. If you follow
2525
this rule, then you can run all of your application's tests with the following
2626
command:
2727

@@ -686,7 +686,7 @@ their type::
686686
Testing Configuration
687687
---------------------
688688

689-
The Client used by functional tests creates a Kernel that runs in a special
689+
The client used by functional tests creates a Kernel that runs in a special
690690
``test`` environment. Since Symfony loads the ``app/config/config_test.yml``
691691
in the ``test`` environment, you can tweak any of your application's settings
692692
specifically for testing.
@@ -766,47 +766,76 @@ PHPUnit Configuration
766766
~~~~~~~~~~~~~~~~~~~~~
767767

768768
Each application has its own PHPUnit configuration, stored in the
769-
``phpunit.xml.dist`` file. You can edit this file to change the defaults or
770-
create a ``phpunit.xml`` file to tweak the configuration for your local machine.
769+
``app/phpunit.xml.dist`` file. You can edit this file to change the defaults or
770+
create a ``app/phpunit.xml`` file to setup a configuration for your local
771+
machine only.
771772

772773
.. tip::
773774

774-
Store the ``phpunit.xml.dist`` file in your code repository, and ignore the
775+
Store the ``phpunit.xml.dist`` file in your code repository and ignore the
775776
``phpunit.xml`` file.
776777

777-
By default, only the tests stored in "standard" bundles are run by the
778-
``phpunit`` command (standard being tests in the ``src/*/*Bundle/Tests`` or
779-
``src/*/Bundle/*Bundle/Tests`` directories) But you can easily add more
780-
directories. For instance, the following configuration adds the tests from
781-
the installed third-party bundles:
778+
By default, only the tests from your own custom bundles stored in the standard
779+
directories ``src/*/*Bundle/Tests`` or ``src/*/Bundle/*Bundle/Tests`` are run
780+
by the ``phpunit`` command:
782781

783782
.. code-block:: xml
784783
785-
<!-- hello/phpunit.xml.dist -->
786-
<testsuites>
787-
<testsuite name="Project Test Suite">
788-
<directory>../src/*/*Bundle/Tests</directory>
789-
<directory>../src/Acme/Bundle/*Bundle/Tests</directory>
790-
</testsuite>
791-
</testsuites>
784+
<!-- app/phpunit.xml.dist -->
785+
786+
<phpunit>
787+
<!-- ... -->
788+
<testsuites>
789+
<testsuite name="Project Test Suite">
790+
<directory>../src/*/*Bundle/Tests</directory>
791+
<directory>../src/*/Bundle/*Bundle/Tests</directory>
792+
</testsuite>
793+
</testsuites>
794+
<!-- ... -->
795+
</phpunit>
796+
797+
But you can easily add more directories. For instance, the following
798+
configuration adds tests from a custom ``lib/tests`` directory:
799+
800+
.. code-block:: xml
801+
802+
<!-- app/phpunit.xml.dist -->
803+
804+
<phpunit>
805+
<!-- ... -->
806+
<testsuites>
807+
<testsuite name="Project Test Suite">
808+
<!-- ... --->
809+
<directory>../lib/tests</directory>
810+
</testsuite>
811+
</testsuites>
812+
<!-- ... --->
813+
</phpunit>
792814
793815
To include other directories in the code coverage, also edit the ``<filter>``
794816
section:
795817

796818
.. code-block:: xml
797819
798-
<!-- ... -->
799-
<filter>
800-
<whitelist>
801-
<directory>../src</directory>
802-
<exclude>
803-
<directory>../src/*/*Bundle/Resources</directory>
804-
<directory>../src/*/*Bundle/Tests</directory>
805-
<directory>../src/Acme/Bundle/*Bundle/Resources</directory>
806-
<directory>../src/Acme/Bundle/*Bundle/Tests</directory>
807-
</exclude>
808-
</whitelist>
809-
</filter>
820+
<!-- app/phpunit.xml.dist -->
821+
822+
<phpunit>
823+
<!-- ... -->
824+
<filter>
825+
<whitelist>
826+
<directory>../src</directory>
827+
<directory>../lib</directory>
828+
<exclude>
829+
<directory>../src/*/*Bundle/Resources</directory>
830+
<directory>../src/*/*Bundle/Tests</directory>
831+
<directory>../src/*/Bundle/*Bundle/Resources</directory>
832+
<directory>../src/*/Bundle/*Bundle/Tests</directory>
833+
<directory>../lib/tests</directory>
834+
</exclude>
835+
</whitelist>
836+
</filter>
837+
<!-- ... --->
838+
</phpunit>
810839
811840
Learn more
812841
----------

0 commit comments

Comments
 (0)