diff options
Diffstat (limited to 'doc/tests.markdown')
-rw-r--r-- | doc/tests.markdown | 128 |
1 files changed, 42 insertions, 86 deletions
diff --git a/doc/tests.markdown b/doc/tests.markdown index 5e5ad389..b2d95491 100644 --- a/doc/tests.markdown +++ b/doc/tests.markdown @@ -1,7 +1,7 @@ -How to run units and functional tests? -====================================== +Automated tests +=============== -[PHPUnit](https://phpunit.de/) is used to run automatic tests on Kanboard. +[PHPUnit](https://phpunit.de/) is used to run automated tests on Kanboard. You can run tests across different databases (Sqlite, Mysql and Postgresql) to be sure that the result is the same everywhere. @@ -9,31 +9,18 @@ Requirements ------------ - Linux/Unix machine -- PHP command line +- PHP cli - PHPUnit installed - Mysql and Postgresql (optional) -Install the latest version of PHPUnit -------------------------------------- - -Simply download the PHPUnit PHAR et copy the file somewhere in your `$PATH`: - -```bash -wget https://phar.phpunit.de/phpunit.phar -chmod +x phpunit.phar -sudo mv phpunit.phar /usr/local/bin/phpunit -phpunit --version -PHPUnit 4.2.6 by Sebastian Bergmann. -``` - -Running unit tests ------------------- +Unit Tests +---------- -### Testing with Sqlite +### Test with Sqlite Sqlite tests use a in-memory database, nothing is written on the file system. -The config file is `tests/units.sqlite.xml`. +The PHPUnit config file is `tests/units.sqlite.xml`. From your Kanboard directory, run the command `phpunit -c tests/units.sqlite.xml`. Example: @@ -41,21 +28,26 @@ Example: ```bash phpunit -c tests/units.sqlite.xml -PHPUnit 4.2.6 by Sebastian Bergmann. +PHPUnit 5.0.0 by Sebastian Bergmann and contributors. -Configuration read from /Volumes/Devel/apps/kanboard/tests/units.sqlite.xml +............................................................... 63 / 649 ( 9%) +............................................................... 126 / 649 ( 19%) +............................................................... 189 / 649 ( 29%) +............................................................... 252 / 649 ( 38%) +............................................................... 315 / 649 ( 48%) +............................................................... 378 / 649 ( 58%) +............................................................... 441 / 649 ( 67%) +............................................................... 504 / 649 ( 77%) +............................................................... 567 / 649 ( 87%) +............................................................... 630 / 649 ( 97%) +................... 649 / 649 (100%) -................................................................. 65 / 74 ( 87%) -......... +Time: 1.22 minutes, Memory: 151.25Mb -Time: 9.05 seconds, Memory: 17.75Mb - -OK (74 tests, 6145 assertions) +OK (649 tests, 43595 assertions) ``` -**NOTE:** PHPUnit is already included in the Vagrant environment - -### Testing with Mysql +### Test with Mysql You must have Mysql or MariaDb installed on localhost. @@ -68,27 +60,10 @@ By default, those credentials are used: For each execution the database is dropped and created again. -The config file is `tests/units.mysql.xml`. +The PHPUnit config file is `tests/units.mysql.xml`. From your Kanboard directory, run the command `phpunit -c tests/units.mysql.xml`. -Example: - -```bash -phpunit -c tests/units.mysql.xml - -PHPUnit 4.2.6 by Sebastian Bergmann. - -Configuration read from /Volumes/Devel/apps/kanboard/tests/units.mysql.xml - -................................................................. 65 / 74 ( 87%) -......... - -Time: 49.77 seconds, Memory: 17.50Mb - -OK (74 tests, 6145 assertions) -``` - -### Testing with Postgresql +### Test with Postgresql You must have Postgresql installed on localhost. @@ -100,37 +75,20 @@ By default, those credentials are used: - Database: **kanboard_unit_test** Be sure to allow the user `postgres` to create and drop databases. -For each execution the database is dropped and created again. +The database is recreated for each execution. -The config file is `tests/units.postgres.xml`. +The PHPUnit config file is `tests/units.postgres.xml`. From your Kanboard directory, run the command `phpunit -c tests/units.postgres.xml`. -Example: - -```bash -phpunit -c tests/units.postgres.xml - -PHPUnit 4.2.6 by Sebastian Bergmann. - -Configuration read from /Volumes/Devel/apps/kanboard/tests/units.postgres.xml - -................................................................. 65 / 74 ( 87%) -......... - -Time: 52.66 seconds, Memory: 17.50Mb - -OK (74 tests, 6145 assertions) -``` - -Running functionals tests -------------------------- +Integration Tests +----------------- Actually only the API calls are tested. Real HTTP calls are made with those tests. -So a local instance of Kanboard is necessary and must listen on `http://localhost:8000`. +So a local instance of Kanboard is necessary and must listen on `http://localhost:8000/`. -Don't forget that all data will be removed/altered by the test suite. +All data will be removed/altered by the test suite. Moreover the script will reset and set a new API key. 1. Start a local instance of Kanboard `php -S 127.0.0.1:8000` @@ -138,27 +96,27 @@ Moreover the script will reset and set a new API key. The same method as above is used to run tests across different databases: -- Sqlite: `phpunit -c tests/functionals.sqlite.xml` -- Mysql: `phpunit -c tests/functionals.mysql.xml` -- Postgresql: `phpunit -c tests/functionals.postgres.xml` +- Sqlite: `phpunit -c tests/integration.sqlite.xml` +- Mysql: `phpunit -c tests/integration.mysql.xml` +- Postgresql: `phpunit -c tests/integration.postgres.xml` Example: ```bash -phpunit -c tests/functionals.sqlite.xml - -PHPUnit 4.2.6 by Sebastian Bergmann. +phpunit -c tests/integration.sqlite.xml -Configuration read from /Volumes/Devel/apps/kanboard/tests/functionals.sqlite.xml +PHPUnit 5.0.0 by Sebastian Bergmann and contributors. -.......................................... +............................................................... 63 / 135 ( 46%) +............................................................... 126 / 135 ( 93%) +......... 135 / 135 (100%) -Time: 1.72 seconds, Memory: 4.25Mb +Time: 1.18 minutes, Memory: 14.75Mb -OK (42 tests, 160 assertions) +OK (135 tests, 526 assertions) ``` -Continuous Integration with Travis-ci +Continuous Integration with Travis-CI ------------------------------------- After each commit pushed on the main repository, unit tests are executed across 5 different versions of PHP: @@ -171,6 +129,4 @@ After each commit pushed on the main repository, unit tests are executed across Each version of PHP is tested against the 3 supported database: Sqlite, Mysql and Postgresql. -That mean we run 15 jobs each time the repository is updated. The execution time is around 25 minutes. - The Travis config file `.travis.yml` is located on the root directory of Kanboard. |