aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc/Running-unit-tests.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/Running-unit-tests.md')
-rw-r--r--doc/Running-unit-tests.md127
1 files changed, 0 insertions, 127 deletions
diff --git a/doc/Running-unit-tests.md b/doc/Running-unit-tests.md
deleted file mode 100644
index 94e99591..00000000
--- a/doc/Running-unit-tests.md
+++ /dev/null
@@ -1,127 +0,0 @@
1
2### Setup your environment for tests
3The framework used is [PHPUnit](https://phpunit.de/); it can be installed with [Composer](https://getcomposer.org/), which is a dependency management tool.
4
5Regarding Composer, you can either use:
6* a system-wide version, e.g. installed through your distro's package manager
7* a local version, downloadable [here](https://getcomposer.org/download/)
8
9#### Sample usage
10```bash
11# system-wide version
12$ composer install
13$ composer update
14
15# local version
16$ php composer.phar self-update
17$ php composer.phar install
18$ php composer.phar update
19```
20
21#### Install Shaarli dev dependencies
22```bash
23$ cd /path/to/shaarli
24$ composer update
25```
26
27#### Install and enable Xdebug to generate PHPUnit coverage reports
28For Debian-based distros:
29```bash
30$ aptitude install php5-xdebug
31```
32For ArchLinux:
33```bash
34$ pacman -S xdebug
35```
36
37Then add the following line to `/etc/php/php.ini`:
38```ini
39zend_extension=xdebug.so
40```
41
42#### Run unit tests
43Successful test suite:
44```bash
45$ make test
46
47-------
48PHPUNIT
49-------
50PHPUnit 4.6.9 by Sebastian Bergmann and contributors.
51
52Configuration read from /home/virtualtam/public_html/shaarli/phpunit.xml
53
54....................................
55
56Time: 759 ms, Memory: 8.25Mb
57
58OK (36 tests, 65 assertions)
59```
60
61Test suite with failures and errors:
62```bash
63$ make test
64-------
65PHPUNIT
66-------
67PHPUnit 4.6.9 by Sebastian Bergmann and contributors.
68
69Configuration read from /home/virtualtam/public_html/shaarli/phpunit.xml
70
71E..FF...............................
72
73Time: 802 ms, Memory: 8.25Mb
74
75There was 1 error:
76
771) LinkDBTest::testConstructLoggedIn
78Missing argument 2 for LinkDB::__construct(), called in /home/virtualtam/public_html/shaarli/tests/Link\
79DBTest.php on line 79 and defined
80
81/home/virtualtam/public_html/shaarli/application/LinkDB.php:58
82/home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:79
83
84--
85
86There were 2 failures:
87
881) LinkDBTest::testCheckDBNew
89Failed asserting that two strings are equal.
90--- Expected
91+++ Actual
92@@ @@
93-'e3edea8ea7bb50be4bcb404df53fbb4546a7156e'
94+'85eab0c610d4f68025f6ed6e6b6b5fabd4b55834'
95
96/home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:121
97
982) LinkDBTest::testCheckDBLoad
99Failed asserting that two strings are equal.
100--- Expected
101+++ Actual
102@@ @@
103-'e3edea8ea7bb50be4bcb404df53fbb4546a7156e'
104+'85eab0c610d4f68025f6ed6e6b6b5fabd4b55834'
105
106/home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:133
107
108FAILURES!
109Tests: 36, Assertions: 63, Errors: 1, Failures: 2.
110```
111
112#### Test results and coverage
113By default, PHPUnit will run all suitable tests found under the `tests` directory.
114
115Each test has 3 possible outcomes:
116* `.` - success
117* `F` - failure: the test was run but its results are invalid
118 * the code does not behave as expected
119 * dependencies to external elements: globals, session, cache...
120* `E` - error: something went wrong and the tested code has crashed
121 * typos in the code, or in the test code
122 * dependencies to missing external elements
123
124If Xdebug has been installed and activated, two coverage reports will be generated:
125* a summary in the console
126* a detailed HTML report with metrics for tested code
127 * to open it in a web browser: `firefox coverage/index.html &` \ No newline at end of file