Page 1 of 1

Code Coverage using PHPunit 3.4.5

Posted: Tue Aug 17, 2010 8:35 am
by ranjakum
Hi All,

I am new to php and i am stuck in generating code coverage report for the code base.
I am unsure how to do it programmatically.I am using following code snippet to do the same
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTest(new TestMyAPI('testA'));
$suite->addTest(new TestMyAPI('testB'));
$suite->addTest(new TestMyAPI('testC'));
$suite->addTest(new TestMyAPI('testD'));


$result = PHPUnit_TextUI_TestRunner::run($suite);


//$sutData = $result->getCodeCoverageInformation();
//$sutFiles = PHPUnit_Util_CodeCoverage::getSummary($sutData, TRUE);
//var_dump( $sutFiles );

But somehow $result->getCodeCoverageInformation(); results in a null array.Somebody plz help me to resolve this.

Re: Code Coverage using PHPunit 3.4.5

Posted: Tue Aug 17, 2010 10:19 am
by Weirdan
Do you have xdebug installed? PHPUnit uses xdebug to get code coverage data.

Re: Code Coverage using PHPunit 3.4.5

Posted: Tue Aug 17, 2010 11:11 pm
by ranjakum
I guess XDebug is not installed , but then when i generate it from command line using command phpunit --coverage-html ./report BankAccountTest.php it generates the report and also says using XDebug <version_number>.Its confusing

Re: Code Coverage using PHPunit 3.4.5

Posted: Tue Aug 17, 2010 11:17 pm
by ranjakum
Ok Sorry , I am already running the latest version of XDebug