Skip to content

Commit f3ec9cf

Browse files
authored
Merge pull request #6865 from paulbalandan/tests-readme
Update README for tests
2 parents 51b2b1d + fd90479 commit f3ec9cf

1 file changed

Lines changed: 28 additions & 13 deletions

File tree

tests/README.md

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@ writing we are running version 9.x. Support for this has been built into the
1919
via [Composer](https://getcomposer.org/) if you don't already have it installed globally.
2020

2121
```console
22-
> composer install
22+
composer install
2323
```
2424

2525
If running under macOS or Linux, you can create a symbolic link to make running tests a touch nicer.
2626

2727
```console
28-
> ln -s ./vendor/bin/phpunit ./phpunit
28+
ln -s ./vendor/bin/phpunit ./phpunit
2929
```
3030

31-
You also need to install [XDebug](https://xdebug.org/docs/install) in order
32-
for code coverage to be calculated successfully. After installing `XDebug`, you must add `xdebug.mode=coverage` in the **php.ini** file to enable code coverage.
31+
You also need to install [Xdebug](https://xdebug.org/docs/install) in order
32+
for code coverage to be calculated successfully. After installing `Xdebug`, you must
33+
add `xdebug.mode=coverage` in the **php.ini** file to enable code coverage.
3334

3435
## Setting Up
3536

@@ -56,41 +57,55 @@ More details on a test database setup are in the
5657
[Testing Your Database](https://codeigniter4.github.io/CodeIgniter4/testing/database.html) section of the documentation.
5758

5859
If you want to run the tests without using live database you can
59-
exclude `@DatabaseLive` group. Or make a copy of **phpunit.dist.xml** -
60-
call it **phpunit.xml** - and comment out the `<testsuite>` named `Database`. This will make
61-
the tests run quite a bit faster.
60+
exclude `@DatabaseLive` group. This will make the tests run quite a bit faster.
61+
62+
## Groups
63+
64+
Each test class that we are running should belong to at least one
65+
[@group](https://phpunit.readthedocs.io/en/9.5/annotations.html#group) that is written at class-level
66+
doc block.
67+
68+
The available groups to use are:
69+
70+
| Group | Purpose |
71+
| --------------- | --------------------------------------------------------------------- |
72+
| AutoReview | Used for tests that perform automatic code reviews |
73+
| CacheLive | Used for cache tests that need external services (redis, memcached) |
74+
| DatabaseLive | Used for database tests that need to run on actual database drivers |
75+
| SeparateProcess | Used for tests that need to run on separate PHP processes |
76+
| Others | Used as a "catch-all" group for tests not falling in the above groups |
6277

6378
## Running the tests
6479

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

6782
```console
68-
> ./phpunit
83+
./phpunit
6984
```
7085

7186
If you are using Windows, use the following command.
7287

7388
```console
74-
> vendor\bin\phpunit
89+
vendor\bin\phpunit
7590
```
7691

7792
You can limit tests to those within a single test directory by specifying the
7893
directory name after phpunit. All core tests are stored under **tests/system**.
7994

8095
```console
81-
> ./phpunit tests/system/HTTP/
96+
./phpunit tests/system/HTTP/
8297
```
8398

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

86101
```console
87-
> ./phpunit tests/system/HTTP/RequestTest.php
102+
./phpunit tests/system/HTTP/RequestTest.php
88103
```
89104

90105
You can run the tests without running the live database and the live cache tests.
91106

92107
```console
93-
> ./phpunit --exclude-group DatabaseLive,CacheLive
108+
./phpunit --exclude-group DatabaseLive,CacheLive
94109
```
95110

96111
## Generating Code Coverage
@@ -99,7 +114,7 @@ To generate coverage information, including HTML reports you can view in your br
99114
you can use the following command:
100115

101116
```console
102-
> ./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m
117+
./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m
103118
```
104119

105120
This runs all of the tests again collecting information about how many lines,

0 commit comments

Comments
 (0)