我正在使用
PHPUnit 9.6.10 由 Sebastian Bergmann 和贡献者编写。
当我运行 phpunit 时为什么会看到以下错误?
Argument 1 passed to PHPUnit\Runner\TestSuiteSorter::reorderTestsInSuite()
must be an instance of PHPUnit\Framework\Test,
instance of PHPUnit\Framework\TestSuite given,
called in /root/.config/composer/vendor/phpunit/phpunit/src/TextUI/TestRunner.php on line 207
对我来说,原因是因为我正在测试的一个文件需要另一个文件,该文件需要使用相对 url 路径的文件。
例如,我可以通过相对路径看到此错误。
<?php
require_once 'fileOne.php';
require_once 'fileTwo.php';
但是当我将这些更改为绝对路径时,它解决了问题
<?php
require_once __DIR__ . '/fileOne.php';
require_once __DIR__ . '/fileTwo.php';
故事的寓意。不要使用相对路径。