11# Running System Tests
22
33This 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.
4+ it takes to set up your application and get it ready to run unit tests.
55It 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.
6+ use to test your application. Those details can be found in the documentation.
77
88## Requirements
99
1010It is recommended to use the latest version of PHPUnit. At the time of this
1111writing 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
12+ ** composer.json** file that ships with CodeIgniter and can easily be installed
1313via [ Composer] ( https://getcomposer.org/ ) if you don't already have it installed globally.
1414
1515 > composer install
@@ -19,23 +19,24 @@ If running under OS X or Linux, you can create a symbolic link to make running t
1919 > ln -s ./vendor/bin/phpunit ./phpunit
2020
2121You also need to install [ XDebug] ( https://xdebug.org/index.php ) in order
22- for the unit tests to successfully complete .
22+ for code coverage to be calculated successfully .
2323
24- ## Setup
24+ ## Setting Up
2525
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.
26+ A number of the tests use a running database.
27+ In order to set up the database edit the details for the ` tests ` group in
28+ ** app/Config/Database.php** or ** phpunit.xml ** . Make sure that you provide a database engine
29+ that is currently running on your machine. More details on a test database setup are in the
30+ * Docs>>Testing>>Testing Your Database * section of the documentation.
3131
32- A simplified PHPunit configuration file, ** phpunit.dist.xml** , is provided.
33- You can use it as is, or copy it to ** phpunit.xml** , and tailor it to suit your
34- application.
32+ If you want to run the tests without using live database you can
33+ exclude @DatabaseLive group. Or make a copy of ** phpunit.dist.xml** -
34+ call it ** phpunit.xml** - and comment out the <testsuite > named "database". This will make
35+ the tests run quite a bit faster.
3536
3637## Running the tests
3738
38- The entire test suite can be ran by simply typing one command from the command line within the main directory.
39+ The entire test suite can be run by simply typing one command-line command from the main directory.
3940
4041 > ./phpunit
4142
@@ -51,9 +52,21 @@ you can use the following command:
5152
5253 > ./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m
5354
54- This runs all of the tests again, collecting information about how many lines,
55- functions, and files are tested, and the percent of the code that is covered by the tests.
56- It is collected in two formats: a simple text file that provides an overview,
57- as well as comprehensive collection of HTML files that show the status of every line of code in the project.
55+ This runs all of the tests again collecting information about how many lines,
56+ functions, and files are tested. It also reports the percentage of the code that is covered by tests.
57+ It is collected in two formats: a simple text file that provides an overview as well
58+ as a comprehensive collection of HTML files that show the status of every line of code in the project.
5859
59- Code coverage details will be left in the ** tests/coverage** folder.
60+ The text file can be found at ** tests/coverage.txt** .
61+ The HTML files can be viewed by opening ** tests/coverage/index.html** in your favorite browser.
62+
63+ ## PHPUnit XML Configuration
64+
65+ The repository has a `` phpunit.xml.dist `` file in the project root that's used for
66+ PHPUnit configuration. This is used to provide a default configuration if you
67+ do not have your own configuration file in the project root.
68+
69+ The normal practice would be to copy `` phpunit.xml.dist `` to `` phpunit.xml ``
70+ (which is git ignored), and to tailor it as you see fit.
71+ For instance, you might wish to exclude database tests, or automatically generate
72+ HTML code coverage reports.
0 commit comments