Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPUnit - Trying to @cover not existing method

My test case looks like this:

class FooTest extends PHPUnit_Framework_TestCase {

    /** @covers MyClass::bar */
    function testBar()
    {
        $result = MyClass::bar();
        $this->assertSomething($result);
    }

}

Now, the test itself works perfectly fine but code coverage complains with:

PHP_CodeCoverage_Exception: Trying to @cover not existing method "MyClass::bar *//**".

Any ideas?

like image 310
Duru Can Celasun Avatar asked Mar 02 '26 07:03

Duru Can Celasun


1 Answers

Another reason (which was the reason in my case) is not using the complete classname including the namespace.

// Should be like
@covers \Vendor\Module\MyClass::doSomething
like image 70
Czar Pino Avatar answered Mar 03 '26 20:03

Czar Pino