Difficulties with PHPUnit and MAMP

  • From: "joboh" < >
  • To:
  • Subject: Difficulties with PHPUnit and MAMP
  • Date: Sun, 10 Feb 2013 17:09:38 -0500

Hello!

I've tried for some time to get working PHPUnit tests with code coverage in 
NetBeans 7.3 but it wasn't successful, yet.

My setup so far:
- NetBeans 7.3 Beta2
- MacOS X 10.8.2 with MAMP 2.1.2:
- PHP 5.4.10 with XDebug 2.2.1 and PHPUnit 3.7.13

XDebug configuration (works fine for debugging):


Code:
[xdebug]
zend_extension="/Applications/MAMP/bin/php/php5.4.10/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so"
xdebug.remote_enable=0
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000



I created the usual Calculator class:


Code:
class Calculator
{
    public static function add($a, $b)
    {
        return $a + $b;
    }
}
echo Calculator::add(2, 3);



And generated the test class with the PHPUnit Skeleton generator within 
NetBeans:


Code:
class CalculatorTest extends PHPUnit_Framework_TestCase {

    protected $object;
    
    protected function setUp() {
        $this->object = new Calculator;
    }

    protected function tearDown() {
        
    }

    public function testAdd() {
        $this->assertTrue(true);
    }
}



When I now try to run the test, I get the following output in the "Test 
Results" window:


Code:
Perhaps an error occurred, verify in Output window.



The output window shows the following:


Code:
PHPUnit 3.7.13 by Sebastian Bergmann.

The Xdebug extension is not loaded. No code coverage will be generated.



I checked the setup several times. XDebug seems to work fine with Netbeans. 
At least I'm able to debug the example posted before. The executable paths 
are all set properly and the general include path contains the location where 
the PHPUnit files are located 
(/Applications/MAMP/bin/php/php5.4.10/lib/php/PHPUnit)

One strange thing is, that when I change the generated test case to the 
following:


Code:
class CalculatorTest extends PHPUnit_Framework_TestCase {

    protected function setUp() {
        
    }

    protected function tearDown() {
        
    }

    public function testAdd() {
        $this->assertTrue(true);
    }
}



I can run the test and I get a positive result. Anyway code coverage is still 
not collected. :(

I don't know how I can fix this issue or how I can get my tests working 
properly with code coverage. Maybe someone here has an idea or the same 
problem and can help me? 

Thank you very much!

Regards,
Johanna






Difficulties with PHPUnit and MAMP

joboh 02/10/2013

Re: Difficulties with PHPUnit and MAMP

Tomas Mysik 02/11/2013

Difficulties with PHPUnit and MAMP

joboh 02/13/2013

Re: Difficulties with PHPUnit and MAMP

Tomas Mysik 02/15/2013

Difficulties with PHPUnit and MAMP

joboh 02/16/2013

Project Features

About this Project

PHP was started in November 2009, is owned by Petr Jiricka, and has 235 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close