I have this test in my Laravel project:
// here are some test function configurations
// found nothing if not match
$this->post(action([TagController::class, 'search'], '!! Not foundable name !!'))
->assertOk()
->assertJsonCount(0, 'data');
// found it if match
$this->post(action([TagController::class, 'search'], $matchName))
->assertOk()
->assertJsonCount(1, 'data');
// found it if partly match
$this->post(action([TagController::class, 'search'], $partlyMatchName))
->assertOk()
->assertJsonCount(1, 'data');
Now I see this result if test failed:
Failed to assert that the response count matched the expected 0
Failed asserting that actual size 4 matches expected size 0.
This isn't say too mutch for me, I don't see which assertation failed and exactly why. I want to define custom message for this case.
I want to do someting like this:
->assertJsonCount(
0,
'data',
'It should found noting, because of conditions are not match'
);
Is there any way to send custom message to the tester user in this case?