以下 PHPUnit 代码取自他们自己的网站,它对我不起作用,即使文档说它正在工作。
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
final class MultipleDependenciesTest extends TestCase
{
public function testProducerFirst(): string
{
$this->assertTrue(true);
return 'first';
}
public function testProducerSecond(): string
{
$this->assertTrue(true);
return 'second';
}
/**
* @depends testProducerFirst
* @depends testProducerSecond
*/
public function testConsumer(string $a, string $b): void
{
$this->assertSame('first', $a);
$this->assertSame('second', $b);
}
}
我收到以下错误:
- MultipleDependencyTest::testConsumer ArgumentCountError: Too few arguments to function MultipleDependencyTest::testConsumer(), 0 passed and exactly 2 expected`
最佳答案
升级/降级 PHPUnit 和 PHP 版本即可解决问题。尝试按照@AymDev 在评论中的建议进行设置。
关于PHP 单元 9 : Test Dependencies does not work for me,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65140646/