我不得不承认这是我第一次使用这种方法
在描述之前,这里是本案例中的 Laravel 和 PHP 版本。Laravel:8.15 PHP:7.4.13
- 我的路线:
Route::get('/', function () {
return ['a' => 1, 'b' => 2, 'c' => 3];
- 当我的测试方法如下时,它失败了,这是我的预期
public function testDemo()
{
$response = $this->get('/')->assertJsonMissing(['a' => 1, 'b' => 3]);
}
- 然后,我使用了 assertJsonMissingExact,我预计它会通过。
public function testDemo()
{
$response = $this->get('/')->assertJsonMissingExact(['a' => 1, 'b' => 3]);
}
- 然而,它没有通过。相反,这是消息
This test did not perform any assertions
Time: 00:00.178, Memory: 20.00 MB
OK, but incomplete, skipped, or risky tests!
Tests: 1, Assertions: 0, Risky: 1.
Process finished with exit code 0
它说测试没有执行任何断言。我想知道这是否正常?因为我期待一个passed
结果。
任何人都可以帮助我,将不胜感激。