From a2b235371e83b81bf15c7e367820f16e308fed6d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 Feb 2011 10:25:13 +0000 Subject: [PATCH] Change to make unit test easier --- pom.xml | 14 ++++++++++++++ test/.cvsignore | 1 + test/phpunit/AdherentTest.php | 3 +-- test/phpunit/{MyTestSuite.php => AllTests.php} | 4 ++-- test/phpunit/README | 15 +++++++++------ test/phpunit/phpunittest.xml | 1 + 6 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 pom.xml create mode 100644 test/.cvsignore rename test/phpunit/{MyTestSuite.php => AllTests.php} (98%) diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000000..bde1159e181 --- /dev/null +++ b/pom.xml @@ -0,0 +1,14 @@ + + +4.0.0 +org.dolibarr +dolibarr +dolibarr +1.0 +pom + + test/report + htdocs + test/phpunit + + \ No newline at end of file diff --git a/test/.cvsignore b/test/.cvsignore new file mode 100644 index 00000000000..05c31926438 --- /dev/null +++ b/test/.cvsignore @@ -0,0 +1 @@ +report diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index b4f475bd27b..50291da9270 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -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); diff --git a/test/phpunit/MyTestSuite.php b/test/phpunit/AllTests.php similarity index 98% rename from test/phpunit/MyTestSuite.php rename to test/phpunit/AllTests.php index c48cb1efcf7..25c47026265 100644 --- a/test/phpunit/MyTestSuite.php +++ b/test/phpunit/AllTests.php @@ -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() { diff --git a/test/phpunit/README b/test/phpunit/README index 9df6b76a4f7..5e3c648334b 100644 --- a/test/phpunit/README +++ b/test/phpunit/README @@ -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 - \ No newline at end of file +* 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 diff --git a/test/phpunit/phpunittest.xml b/test/phpunit/phpunittest.xml index c60d56bbc18..d45b89c8494 100644 --- a/test/phpunit/phpunittest.xml +++ b/test/phpunit/phpunittest.xml @@ -3,6 +3,7 @@ + /home/ldestail/workspace/dolibarr/htdocs/includes/smarty/libs/ ../CVS/ ../../test/ ../../htdocs/includes/adodbtime/