You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/README.md
+44-10Lines changed: 44 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,30 +1,47 @@
1
1
# Running System Tests
2
2
3
-
This is the preliminary quick-start to CodeIgniter testing. Its intent is to describe what it takes to get your system setup and ready to run the system tests. It is not intended to be a full description of the test features that you can use to test your application, since that can be found in the documentation.
3
+
This is the quick-start to CodeIgniter testing. Its intent is to describe what
4
+
it takes to get your system setup and ready to run the system tests.
5
+
It is not intended to be a full description of the test features that you can
6
+
use to test your application, since that can be found in the documentation.
4
7
5
8
## Requirements
6
9
7
-
It is recommended to use the latest version of PHPUnit. At the time of this writing we are running version 5.3. Support for this has been built into the **composer.json** file that ships with CodeIgniter, and can easily be installed via [Composer](https://getcomposer.org/) if you don't already have it installed globally.
10
+
It is recommended to use the latest version of PHPUnit. At the time of this
11
+
writing we are running version 7.5.1. Support for this has been built into the
12
+
**composer.json** file that ships with CodeIgniter, and can easily be installed
13
+
via [Composer](https://getcomposer.org/) if you don't already have it installed globally.
8
14
9
15
> composer install
10
16
11
-
If running under OS X or Linux, you will want to create a symbolic link to make running tests a touch nicer.
17
+
If running under OS X or Linux, you can create a symbolic link to make running tests a touch nicer.
12
18
13
19
> ln -s ./vendor/bin/phpunit ./phpunit
14
20
21
+
You also need to install [XDebug](https://xdebug.org/index.php) in order
22
+
for the unit tests to successfully complete.
23
+
15
24
## Setup
16
25
17
-
A number of the tests that are ran during the test suite are ran against a running database. In order to setup the database used here, edit the details for the `tests` database group in **app/Config/Database.php**. Make sure that you provide a database engine that is currently running, and have already created a table that you can use only for these tests, as it will be wiped and refreshed often while running the test suite.
26
+
A number of the tests that are ran during the test suite are ran against a running database.
27
+
In order to setup the database used here, edit the details for the `tests` database
28
+
group in **app/Config/Database.php**. Make sure that you provide a database engine
29
+
that is currently running, and have already created a table that you can use only
30
+
for these tests, as it will be wiped and refreshed often while running the test suite.
18
31
19
-
If you want to run the tests without running the live database tests, you can exclude @DatabaseLive group. Or make a copy of **phpunit.dist.xml**, call it **phpunit.xml**, and un-comment the line within the testsuite that excludes the **tests/system/Database/Live** directory. This will make the tests run quite a bit faster.
32
+
If you want to run the tests without running the live database tests,
33
+
you can exclude @DatabaseLive group. Or make a copy of **phpunit.dist.xml**,
34
+
call it **phpunit.xml**, and un-comment the line within the testsuite that excludes
35
+
the **tests/system/Database/Live** directory. This will make the tests run quite a bit faster.
20
36
21
37
## Running the tests
22
38
23
39
The entire test suite can be ran by simply typing one command from the command line within the main directory.
24
40
25
41
> ./phpunit
26
42
27
-
You can limit tests to those within a single test directory by specifying the directory name after phpunit. All core tests are stored under **tests/system**.
43
+
You can limit tests to those within a single test directory by specifying the
44
+
directory name after phpunit. All core tests are stored under **tests/system**.
28
45
29
46
> ./phpunit tests/system/HTTP/
30
47
@@ -38,10 +55,27 @@ You can run the tests without running the live database tests.
38
55
39
56
## Generating Code Coverage
40
57
41
-
To generate coverage information, including HTML reports you can view in your browser, you can use the following command:
58
+
To generate coverage information, including HTML reports you can view in your browser,
The repository has a ``phpunit.xml.dist`` file in the project root, used for
74
+
PHPUnit configuration. This is used as a default configuration if you
75
+
do not have your own ``phpunit.xml`` in the project root.
44
76
45
-
This runs all of the tests again, collecting information about how many lines, functions, and files are tested, and the percent of the code that is covered by the tests. It is collected in two formats: a simple text file that provides an overview, as well as comprehensive collection of HTML files that show the status of every line of code in the project.
77
+
The normal practice would be to copy ``phpunit.xml.dist`` to ``phpunit.xml``
78
+
(which is git ignored), and to tailor yours as you see fit.
79
+
For instance, you might wish to exclude database tests
80
+
or automatically generate HTML code coverage reports.
46
81
47
-
The text file can be found at **tests/coverage.txt**. The HTML files can be viewed by opening **tests/coverage/index.html** in your favorite browser.
0 commit comments