PHPUnit - 试图@cover 不存在的方法

标签 php phpunit code-coverage

我的测试用例是这样的:

class FooTest extends PHPUnit_Framework_TestCase {

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

}

现在,测试本身工作得很好,但代码覆盖率提示:

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

有什么想法吗?

最佳答案

另一个原因(在我的例子中就是这个原因)没有使用包括命名空间在内的完整类名。

// Should be like
@covers \Vendor\Module\MyClass::doSomething

关于PHPUnit - 试图@cover 不存在的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12620706/

相关文章:

jestjs - 从Jest到stdout到GitLab的代码覆盖率

来自外部 public_html 的 PHP MySql 请求(Cron 作业)

php - 为什么从我的网络服务器提供的图像不缓存在客户端上?

php - 在 PHP 中编码密码的最佳方式

continuous-integration - CI 管道中的 Kotlin 代码覆盖率

unit-testing - Gradle jacoco 代码覆盖率 - 然后在 Jenkins 中发布/显示

php - 如何通过 URL 传递一个变量的多个值

php - Symfony2 : running automated tests in a custom environment

php - Symfony 表单测试成员函数 create() on null

namespaces - phpunit 类未在测试中加载