Skip to content

Commit

Permalink
Merge pull request #2345 from dafriend/tests_readme_polish
Browse files Browse the repository at this point in the history
Tests readme polish
  • Loading branch information
lonnieezell authored Oct 18, 2019
2 parents baaefe7 + 11a53f3 commit 3ffedff
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Running System Tests

This is the 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 takes to set up your system and get it ready to run unit 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.
use to test your application. Those details can be found in the documentation.

## Requirements

It is recommended to use the latest version of PHPUnit. At the time of this
writing we are running version 7.5.1. Support for this has been built into the
**composer.json** file that ships with CodeIgniter, and can easily be installed
**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.

> composer install
Expand All @@ -19,24 +19,24 @@ If running under OS X or Linux, you can create a symbolic link to make running t
> ln -s ./vendor/bin/phpunit ./phpunit

You also need to install [XDebug](https://xdebug.org/index.php) in order
for the unit tests to successfully complete.
for unit tests to successfully complete.

## Setup
## Setting Up

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.
A number of the tests use a running database.
In order to set up the database edit the details for the `tests` group in
**app/Config/Database.php**. Make sure that you provide a database engine
that is currently running on your machine. More details on a test database setup are in the
*Docs>>Testing>>Testing Your Database* section of the documentation.

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
If you want to run the tests without using live database you can
exclude @DatabaseLive group. Or make a copy of **phpunit.dist.xml** -
call it **phpunit.xml** - and uncomment the line within the <testsuite> that excludes
the **tests/system/Database/Live** directory. This will make the tests run quite a bit faster.

## Running the tests

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

> ./phpunit

Expand All @@ -45,7 +45,7 @@ directory name after phpunit. All core tests are stored under **tests/system**.

> ./phpunit tests/system/HTTP/

Individual tests can be ran by including the relative path to the test file.
Individual tests can be run by including the relative path to the test file.

> ./phpunit tests/system/HTTP/RequestTest

Expand All @@ -60,22 +60,22 @@ you can use the following command:

> ./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m

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.
This runs all of the tests again collecting information about how many lines,
functions, and files are tested. It also reports the percentage of the code that is covered by tests.
It is collected in two formats: a simple text file that provides an overview as well
as a comprehensive collection of HTML files that show the status of every line of code in the project.

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.

## PHPUnit XML Configuration

The repository has a ``phpunit.xml.dist`` file in the project root, used for
PHPUnit configuration. This is used as a default configuration if you
do not have your own ``phpunit.xml`` in the project root.
The repository has a ``phpunit.xml.dist`` file in the project root that's used for
PHPUnit configuration. This is used to provide a default configuration if you
do not have your own configuration file in the project root.

The normal practice would be to copy ``phpunit.xml.dist`` to ``phpunit.xml``
(which is git ignored), and to tailor yours as you see fit.
For instance, you might wish to exclude database tests
or automatically generate HTML code coverage reports.
(which is git ignored), and to tailor it as you see fit.
For instance, you might wish to exclude database tests, or automatically generate
HTML code coverage reports.

0 comments on commit 3ffedff

Please sign in to comment.