Question


Hello again SO!

I'm trying to get PHPunit to run on localhost, here are some of my specs

xDebugger : v 2.2 (enabled)
php : 5.4.3
PHPunit : tried with 3.7.31 && 4.0.17

Running tests works fine, However whenever I use the coverage-html the output is always 0% covered. I've tried this with both version of PHPunit.

Whenever i try the --coverage-text command I get the same result, the tests run fine(fail/success), however the coverage is 0%.
1 test - 1 assertion - 0

For simplicity, I created these two classes :

class my
{
  function method()
   {
    $bool = true;
    echo $bool;
   }
}

and the test class :

require_once 'my.php';
class myTest extends PHPUnit_Framework_TestCase
{
function testequal()
    {
    $bool = true;
    echo $bool;
    $this->assertTrue($bool);
    }
}

two different files, the file names are my.php and myTest.php.
If I can provide anymore information please let me know, Thanks in advance.

Was it helpful?

Solution

You're actually not testing the code of my. Isn't it? That's why the coverage is 0%.

Change the test code to this:

require_once 'my.php';
class myTest extends PHPUnit_Framework_TestCase
{
    function testSomething()
    {
        $object = new my();
        $this->assertEquals('1', $object->method());
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top