3
3
Running Symfony Tests
4
4
=====================
5
5
6
- Before submitting a :doc: `patch <patches >` for inclusion, you need to run the
7
- Symfony test suite to check that you have not broken anything.
6
+ The Symfony project uses a third-party service which automatically runs tests
7
+ for any submitted :doc: `patch <patches >`. If the new code breaks any test,
8
+ the pull request will show an error message with a link to the full error details.
8
9
9
- PHPUnit
10
- -------
10
+ In any case, it's a good practice to run tests locally before submitting a
11
+ :doc: ` patch < patches >` for inclusion, to check that you have not broken anything.
11
12
12
- To run the Symfony test suite, `install PHPUnit `_ 4.2 (or later) first.
13
+ .. _phpunit :
14
+ .. _dependencies_optional :
13
15
14
- Dependencies (optional)
15
- -----------------------
16
+ Before Running the Tests
17
+ ------------------------
16
18
17
- To run the entire test suite, including tests that depend on external
18
- dependencies, Symfony needs to be able to autoload them. By default, they are
19
- autoloaded from ``vendor/ `` under the main root directory (see
20
- ``autoload.php.dist ``).
21
-
22
- The test suite needs the following third-party libraries:
23
-
24
- * Doctrine
25
- * Swift Mailer
26
- * Twig
27
- * Monolog
28
-
29
- To install them all, use `Composer `_:
30
-
31
- Step 1: :doc: `Install Composer globally </cookbook/composer >`
32
-
33
- Step 2: Install vendors.
19
+ To run the Symfony test suite, `install PHPUnit `_ 4.2 (or later) first. Then,
20
+ install the external dependencies used during the tests, such as Doctrine, Twig
21
+ and Monolog. To do so, :doc: `install Composer </cookbook/composer >` and execute
22
+ the following:
34
23
35
24
.. code-block :: bash
36
25
37
26
$ composer install
38
27
39
- .. note ::
40
-
41
- Note that the script takes some time to finish.
28
+ .. _running :
42
29
43
- After installation, you can update the vendors to their latest version with
44
- the follow command:
45
-
46
- .. code-block :: bash
47
-
48
- $ composer update
49
-
50
- Running
51
- -------
52
-
53
- First, update the vendors (see above).
30
+ Running the Tests
31
+ -----------------
54
32
55
33
Then, run the test suite from the Symfony root directory with the following
56
34
command:
@@ -59,40 +37,17 @@ command:
59
37
60
38
$ phpunit
61
39
62
- The output should display ``OK ``. If not, you need to figure out what's going on
63
- and if the tests are broken because of your modifications .
40
+ The output should display ``OK ``. If not, read the reported errors to figure out
41
+ what's going on and if the tests are broken because of the new code .
64
42
65
43
.. tip ::
66
44
67
- If you want to test a single component type its path after the ``phpunit ``
68
- command, e.g.:
45
+ The entire Symfony suite can take up to several minutes to complete. If you
46
+ want to test a single component, type its path after the ``phpunit `` command,
47
+ e.g.:
69
48
70
49
.. code-block :: bash
71
50
72
51
$ phpunit src/Symfony/Component/Finder/
73
52
74
- .. tip ::
75
-
76
- Run the test suite before applying your modifications to check that they
77
- run fine on your configuration.
78
-
79
- Code Coverage
80
- -------------
81
-
82
- If you add a new feature, you also need to check the code coverage by using
83
- the ``coverage-html `` option:
84
-
85
- .. code-block :: bash
86
-
87
- $ phpunit --coverage-html=cov/
88
-
89
- Check the code coverage by opening the generated ``cov/index.html `` page in a
90
- browser.
91
-
92
- .. tip ::
93
-
94
- The code coverage only works if you have Xdebug enabled and all
95
- dependencies installed.
96
-
97
- .. _install PHPUnit : https://phpunit.de/manual/current/en/installation.html
98
- .. _`Composer` : https://getcomposer.org/
53
+ .. _`install PHPUnit` : https://phpunit.de/manual/current/en/installation.html
0 commit comments