phpBB

Development Wiki

Difference between revisions of "Running Unit Tests"

From phpBB Development Wiki

(Split from Unit_Tests)
 
Line 1: Line 1:
== Running tests on your system ==
 
 
 
This is a job for your command-line/shell.
 
This is a job for your command-line/shell.
First, you need to install PHPUnit to your server: http://www.phpunit.de/
+
 
 +
== 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
 +
 
 +
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:
 
In order to install PHPUnit correctly, you need to run the following commands:
 
<pre>pear channel-update pear.php.net
 
<pre>pear channel-update pear.php.net
Line 11: Line 25:
 
pear install --alldeps phpunit/PHPUnit</pre>
 
pear install --alldeps phpunit/PHPUnit</pre>
  
Once that is done:
+
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.
 
You need to switch into the root directory of the git-repo.
 
And then simply run
 
And then simply run

Revision as of 04:55, 5 September 2011

This is a job for your command-line/shell.

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

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:

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

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:
phpunit
Windows:
YOUR_DIRECTORY_WHERE_THE_FILE_IS/phpunit.bat

(Exp. C:/xampp/php/phpunit.bat )

Afterwards you should see something like:

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.

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.