New: Add phpunit tests

This commit is contained in:
Laurent Destailleur 2010-04-27 09:05:42 +00:00
parent 539c432e91
commit d6e5540a5a
4 changed files with 9 additions and 12 deletions

View File

@ -23,6 +23,9 @@
* \version $Id$ * \version $Id$
* \remarks To run this script as CLI: phpunit filename.php * \remarks To run this script as CLI: phpunit filename.php
*/ */
print "PHP Version: ".phpversion()."\n";
print "Memory: ". ini_get('memory_limit')."\n";
global $conf,$user,$langs,$db; global $conf,$user,$langs,$db;
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
require_once 'PHPUnit/Framework.php'; require_once 'PHPUnit/Framework.php';

View File

@ -16,7 +16,11 @@ If using Eclipse, you must also add an entry as external tool for phpunit progra
Run > phpunit TestFile.php Run > phpunit TestFile.php
If using Eclipse, select the test and click on menu "Run external tools and choose PHPUnit". If using Eclipse, select the test and click on menu "Run external tools and choose PHPUnit".
* Generate a report of Unit tests code coverage: * Generate a report of Unit tests code coverage among tested classes only:
Run > phpunit [--configuration ./phpunittestok.xml] --coverage-html ./report MyTestSuite.php Run > phpunit --coverage-html ./report MyTestSuite.php
Note that xdebug must be installed for this feature to work. Note that xdebug must be installed for this feature to work.
* Generate a report of Unit tests code coverage among all Dolibarr classes:
Increase your PHP memory (memory_limit in php.ini) to 1Gb.
Run > phpunit --configuration ./phpunittest.xml --coverage-html ./report MyTestSuite.php

View File

@ -1,10 +0,0 @@
<phpunit>
<filter>
<blacklist>
<directory suffix=".php">../test/</directory>
</blacklist>
<whitelist>
<directory suffix=".php">../htdocs/</directory>
</whitelist>
</filter>
</phpunit>