phpBB

Development Wiki

Difference between revisions of "Running Unit Tests"

From phpBB Development Wiki

Redirect page
m (3.6 does not install DbUnit, adding it to the command list)
(Redirected page to Automated Tests)
 
Line 1: Line 1:
This is a job for your command-line/shell.
+
#REDIRECT [[Automated_Tests]]
 
+
== Install PHP extensions ==
+
 
+
Unit tests use several PHP extensions that phpBB itself does not use. These need to be installed and enabled for unit tests to work.
+
 
+
Unit tests themselves need:
+
 
+
* ctype
+
* simplexml
+
 
+
For database tests you need to have pdo and pdo drivers for each of the databases you want to test with (e.g. pdo_pgsql for postgres).
+
 
+
phpunit needs:
+
 
+
* ctype
+
* dom
+
 
+
== Installing phpunit ==
+
 
+
You need to install PHPUnit to your server: http://www.phpunit.de/
+
In order to install PHPUnit correctly, you need to run the following commands:
+
<pre>pear channel-update pear.php.net
+
pear install PEAR-1.9.1
+
pear channel-discover pear.phpunit.de
+
pear channel-discover components.ez.no
+
pear channel-discover pear.symfony-project.com
+
pear install --alldeps phpunit/PHPUnit
+
pear install phpunit/DbUnit</pre>
+
 
+
Depending on what versions of phpunit and pear you have installed or had installed earlier, phpunit may silently break itself. If you get errors about missing files when running tests, uninstall phpunit and pear completely and then reinstall the latest versions of pear and phpunit.
+
 
+
== Run Tests ==
+
 
+
You need to switch into the root directory of the git-repo.
+
And then simply run
+
Linux:<pre>phpunit</pre>
+
Windows:<pre>YOUR_DIRECTORY_WHERE_THE_FILE_IS/phpunit.bat</pre>
+
(Exp. C:/xampp/php/phpunit.bat )
+
 
+
Afterwards you should see something like:
+
<pre>PHPUnit 3.4.11 by Sebastian Bergmann.
+
 
+
............................................................  60 / 688
+
............................................................ 120 / 688
+
IIIIIIIIIII................................................. 180 / 688
+
............................................................ 240 / 688
+
............................................................ 300 / 688
+
............................................................ 360 / 688
+
............................................................ 420 / 688
+
............................................................ 480 / 688
+
............................................................ 540 / 688
+
............................................................ 600 / 688
+
............................................................ 660 / 688
+
............................
+
 
+
Time: 5 seconds, Memory: 13.00Mb
+
 
+
OK, but incomplete or skipped tests!
+
Tests: 688, Assertions: 878, Incomplete: 11.</pre>
+
If there are no errors, your test was successful. Otherwise either a test was wrong, or the functionality itself is wrong. Then you should go and fix it.
+
 
+
[[Category:Development]]
+

Latest revision as of 15:35, 21 March 2012