Change to make unit test easier

This commit is contained in:
Laurent Destailleur 2011-02-13 10:25:13 +00:00
parent d71a011ecb
commit a2b235371e
6 changed files with 28 additions and 10 deletions

14
pom.xml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsichemaLocation="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>org.dolibarr</groupId>
<artifactId>dolibarr</artifactId>
<name>dolibarr</name>
<version>1.0</version>
<packaging>pom</packaging>
<build>
<directory>test/report</directory>
<sourceDirectory>htdocs</sourceDirectory>
<testSourceDirectory>test/phpunit</testSourceDirectory>
</build>
</project>

1
test/.cvsignore Normal file
View File

@ -0,0 +1 @@
report

View File

@ -125,8 +125,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase
$localobject=new Adherent($this->savdb);
$localobject->initAsSpecimen();
$result=$localobject->create($user);
$result=$localobject->create($user);
print __METHOD__." result=".$result."\n";
$this->assertLessThan($result, 0);

View File

@ -17,7 +17,7 @@
*/
/**
* \file test/phpunit/MyTestSuite.php
* \file test/phpunit/AllTest.php
* \ingroup test
* \brief This file is a test suite to run all unit tests
* \version $Id$
@ -43,7 +43,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
* Class for the All test suite
*/
class MyTestSuite
class AllTests
{
public static function suite()
{

View File

@ -20,18 +20,21 @@ If using Eclipse, you must also add an entry as external tool for phpunit progra
Windows: "C:\Program Files (x86)\PHPUnit-3.4.9\phpunit.php" ${resource_path}
* Run Unit tests:
Run > phpunit TestFile.php
> cd test
> phpunit MyFileTest.php
If using Eclipse, select the test and click on menu "Run external tools and choose PHPUnit".
* Generate a report of Unit tests code coverage among tested classes only:
Run > phpunit --coverage-html ./report MyTestSuite.php
> cd test
> phpunit -d memory_limit=-1 --configuration ./phpunit/phpunittest.xml --coverage-html ./report --coverage-clover ./report/logs/phpunit.coverage.xml --log-junit ./report/logs/phpunit.xml MyClassTest.php
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 512MB.
Check that you use the "mysqli" driver in your conf.php file (otherwise
edit the file phpunittest.xml).
Run > phpunit --configuration ./phpunittest.xml --coverage-html ./report MyTestSuite.php
> cd test
> phpunit -d memory_limit=-1 --configuration ./phpunit/phpunittest.xml --coverage-html ./report --coverage-clover ./report/logs/phpunit.coverage.xml --log-junit ./report/logs/phpunit.xml AllTests.php
@ -39,6 +42,6 @@ PHPDEPEND
---------
* Install PDepend
* Laucnh PDepend analysis:
pdepend --summary-xml=./report/summary.xml --jdepend-chart=./report/jdepend.svg --overview-pyramid=./report/pyramid.svg /yourdir
* Launch PDepend analysis:
> cd test
> pdepend --debug -d memory_limit=-1 --configuration=./phpunit/phpunittest.xml --phpunit-xml=./report/logs/pdepend.xml --summary-xml=./report/logs/summary.xml --jdepend-chart=./report/logs/jdepend.svg --overview-pyramid=./report/logs/pyramid.svg dirtoscan

View File

@ -3,6 +3,7 @@
<phpunit>
<filter>
<blacklist>
<directory>/home/ldestail/workspace/dolibarr/htdocs/includes/smarty/libs/</directory>
<directory>../CVS/</directory>
<directory>../../test/</directory>
<directory>../../htdocs/includes/adodbtime/</directory>