Skip to content

Commit fb3fa15

Browse files
committed
Update tests/README
1 parent 1aee735 commit fb3fa15

1 file changed

Lines changed: 44 additions & 10 deletions

File tree

tests/README.md

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,47 @@
11
# Running System Tests
22

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.
47

58
## Requirements
69

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.
814

915
> composer install
1016

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.
1218

1319
> ln -s ./vendor/bin/phpunit ./phpunit
1420

21+
You also need to install [XDebug](https://xdebug.org/index.php) in order
22+
for the unit tests to successfully complete.
23+
1524
## Setup
1625

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.
1831

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.
2036

2137
## Running the tests
2238

2339
The entire test suite can be ran by simply typing one command from the command line within the main directory.
2440

2541
> ./phpunit
2642

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**.
2845

2946
> ./phpunit tests/system/HTTP/
3047

@@ -38,10 +55,27 @@ You can run the tests without running the live database tests.
3855

3956
## Generating Code Coverage
4057

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,
59+
you can use the following command:
60+
61+
> ./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m
62+
63+
This runs all of the tests again, collecting information about how many lines,
64+
functions, and files are tested, and the percent of the code that is covered by the tests.
65+
It is collected in two formats: a simple text file that provides an overview,
66+
as well as comprehensive collection of HTML files that show the status of every line of code in the project.
67+
68+
The text file can be found at **tests/coverage.txt**.
69+
The HTML files can be viewed by opening **tests/coverage/index.html** in your favorite browser.
70+
71+
## PHPUnit XML Configuration
4272

43-
> ./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/
73+
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.
4476

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.
4681

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

Comments
 (0)