【发布时间】:2021-10-19 18:04:40
【问题描述】:
我有一个 PHPUnit 测试,其中第三种方法不会接收第二种方法中返回的数组。看看:
<?php
namespace Tests\Unit;
use Tests\TestCase;
class TesteTest extends TestCase
{
public function testFirst()
{
$test = ['id' => 123];
$this->assertNotEmpty($test);
return $test;
}
/** @depends testFirst */
public function testSecond(array $test)
{
$this->assertNotEmpty($test);
}
/** @depends testSecond */
public function testThird(array $test)
{
$this->assertNotEmpty($test);
}
}
这是我从 PHPUnit 得到的回复:
传递给 Tests\Unit\TesteTest::testThird() 的参数 1 必须是数组类型,给定 null,在 C:\Users\edgar\Documents\Projetos\Solarium\solarium-api\vendor\phpunit\ 中调用phpunit\src\Framework\TestCase.php 在第 1527 行
对我可能出错的地方有什么想法吗?
【问题讨论】:
标签: unit-testing phpunit tdd laravel-8