@@ -21,7 +21,7 @@ it has its own excellent `documentation`_.
21
21
needed to test the Symfony core code itself.
22
22
23
23
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
25
25
this rule, then you can run all of your application's tests with the following
26
26
command:
27
27
@@ -686,7 +686,7 @@ their type::
686
686
Testing Configuration
687
687
---------------------
688
688
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
690
690
``test `` environment. Since Symfony loads the ``app/config/config_test.yml ``
691
691
in the ``test `` environment, you can tweak any of your application's settings
692
692
specifically for testing.
@@ -766,47 +766,76 @@ PHPUnit Configuration
766
766
~~~~~~~~~~~~~~~~~~~~~
767
767
768
768
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.
771
772
772
773
.. tip ::
773
774
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
775
776
``phpunit.xml `` file.
776
777
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:
782
781
783
782
.. code-block :: xml
784
783
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 >
792
814
793
815
To include other directories in the code coverage, also edit the ``<filter> ``
794
816
section:
795
817
796
818
.. code-block :: xml
797
819
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 >
810
839
811
840
Learn more
812
841
----------
0 commit comments