PHPUnit ReflectionException 方法套件不存在

2022-01-25 00:00:00 testing php phpunit

我使用的是 PHPUnit 3.6.2 版,并且总是得到

I'm using PHPUnit version 3.6.2, and always got

PHP ReflectionException:第 113 行的/pathTo/pear/PHPUnit/Runner/BaseTestRunner.php 中不存在方法套件

PHP ReflectionException: Method suite does not exist in /pathTo/pear/PHPUnit/Runner/BaseTestRunner.php on line 113

运行单个测试时:

phpunit path/to/my/ClassToTest.php

PHPUnit 使用 pear 安装,我使用的是 php 5.3.6

PHPUnit installed using pear, and I'm using php 5.3.6

我应该修复任何 php 配置吗?或者这只是 PHPUnit 应该解决的问题.

are there any php configurations i should fix? or this just something that PHPUnit should fix.

班级

<?php

class ClassToTest extends PHPUnit_Framework_TestCase{

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

}

推荐答案

如果您使用 VS Code 并在尝试调试单元测试时遇到此异常,请确保 Everything 框没有签入 Breakpoints 窗格.取消选中该框让我摆脱了这个问题:

If you're using VS Code and getting this exception while trying to debug your unit tests, make sure the Everything box is not checked in Breakpoints pane. Unchecking that box got me rid of this issue:

相关文章