11# Running System Tests
22
3- This is the quick-start to CodeIgniter testing. Its intent is to describe what
4- it takes to set up your system and get it ready to run unit tests.
5- It is not intended to be a full description of the test features that you can
6- use to test your application. Those details 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 set up your system and get it ready to run unit tests.
5+ It is not intended to be a full description of the test features that you can
6+ use to test your application. Those details can be found in the documentation.
77
88## Requirements
99
10- It is recommended to use the latest version of PHPUnit. At the time of this
11- writing we are running version 9.x. Support for this has been built into the
12- ** composer.json** file that ships with CodeIgniter and can easily be installed
10+ It is recommended to use the latest version of PHPUnit. At the time of this
11+ writing we are running version 9.x. Support for this has been built into the
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
@@ -23,14 +23,14 @@ for code coverage to be calculated successfully. After installing `XDebug`, you
2323
2424## Setting Up
2525
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
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
3030[ Testing Your Database] ( https://codeigniter4.github.io/CodeIgniter4/testing/database.html ) section of the documentation.
3131
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** -
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** -
3434call it ** phpunit.xml** - and comment out the ` <testsuite> ` named ` Database ` . This will make
3535the tests run quite a bit faster.
3636
@@ -44,7 +44,7 @@ If you are using Windows, use the following command.
4444
4545 > vendor\bin\phpunit
4646
47- You can limit tests to those within a single test directory by specifying the
47+ You can limit tests to those within a single test directory by specifying the
4848directory name after phpunit. All core tests are stored under ** tests/system** .
4949
5050 > ./phpunit tests/system/HTTP/
@@ -59,17 +59,17 @@ You can run the tests without running the live database and the live cache tests
5959
6060## Generating Code Coverage
6161
62- To generate coverage information, including HTML reports you can view in your browser,
63- you can use the following command:
62+ To generate coverage information, including HTML reports you can view in your browser,
63+ you can use the following command:
6464
6565 > ./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m
6666
67- This runs all of the tests again collecting information about how many lines,
68- functions, and files are tested. It also reports the percentage of the code that is covered by tests.
69- It is collected in two formats: a simple text file that provides an overview as well
70- as a comprehensive collection of HTML files that show the status of every line of code in the project.
67+ This runs all of the tests again collecting information about how many lines,
68+ functions, and files are tested. It also reports the percentage of the code that is covered by tests.
69+ It is collected in two formats: a simple text file that provides an overview as well
70+ as a comprehensive collection of HTML files that show the status of every line of code in the project.
7171
72- The text file can be found at ** tests/coverage.txt** .
72+ The text file can be found at ** tests/coverage.txt** .
7373The HTML files can be viewed by opening ** tests/coverage/index.html** in your favorite browser.
7474
7575## PHPUnit XML Configuration
@@ -80,5 +80,5 @@ do not have your own configuration file in the project root.
8080
8181The normal practice would be to copy `` phpunit.xml.dist `` to `` phpunit.xml ``
8282(which is git ignored), and to tailor it as you see fit.
83- For instance, you might wish to exclude database tests, or automatically generate
83+ For instance, you might wish to exclude database tests, or automatically generate
8484HTML code coverage reports.
0 commit comments