Code Coverage using PHPunit 3.4.5

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ranjakum
Forum Newbie
Posts: 3
Joined: Tue Aug 17, 2010 8:21 am

Code Coverage using PHPunit 3.4.5

Post 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.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Code Coverage using PHPunit 3.4.5

Post by Weirdan »

Do you have xdebug installed? PHPUnit uses xdebug to get code coverage data.
ranjakum
Forum Newbie
Posts: 3
Joined: Tue Aug 17, 2010 8:21 am

Re: Code Coverage using PHPunit 3.4.5

Post 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
ranjakum
Forum Newbie
Posts: 3
Joined: Tue Aug 17, 2010 8:21 am

Re: Code Coverage using PHPunit 3.4.5

Post by ranjakum »

Ok Sorry , I am already running the latest version of XDebug
Post Reply